name: cairo-arrays description: Explain Cairo Array usage, ArrayTrait methods, array! macro, Span, and array read/write constraints; use when a request involves creating, updating, reading, or passing arrays in Cairo.
Cairo Arrays
Overview
Explain Cairo Array semantics, method choices, and safe access patterns.
Quick Use
- Read
references/arrays.mdbefore answering. - Provide minimal, compile-ready snippets using
ArrayTraitorarray!. - Call out whether
getoratis appropriate for bounds safety.
Response Checklist
- Use
ArrayTrait::new()orarray![]to construct arrays. - Use
appendto add to the end andpop_frontto remove from the front. - Use
getfor Option-based bounds handling; useatorarr[index]when panicking is desired. - Mention
Spanwhen read-only views are needed.
Example Requests
- "Why can't I modify an element in a Cairo array?"
- "When should I use
getvsat?" - "How do I create an array literal?"