Cairo Structs
Overview
Guide struct definitions, instantiation patterns, and safe field updates.
Quick Use
- •Read
references/structs.mdbefore answering. - •Use clear examples showing
structdefinition andType { field: value }initialization. - •Highlight ownership effects of struct update syntax.
Response Checklist
- •Note that the whole instance must be
mutto change any field. - •Use field init shorthand when variable names match field names.
- •If using update syntax, mention that it moves fields from the source instance.
Example Requests
- •"How do I define a struct with multiple fields in Cairo?"
- •"Why can't I mutate just one struct field without
mut?" - •"How does struct update syntax affect ownership?"