Cairo Match
Overview
Explain how to use match for branching on enum values and destructuring data safely.
Quick Use
- •Read
references/match.mdbefore answering. - •Include an exhaustive
matchwith a_fallback when appropriate. - •Emphasize that all arms must return the same type when used as an expression.
Response Checklist
- •Use fully qualified variants like
EnumName::Variantin patterns. - •Bind inner data with patterns like
EnumName::Variant(value). - •Keep match arms exhaustive; add
_only when appropriate.
Example Requests
- •"How do I match on an Option in Cairo?"
- •"Why is my match non-exhaustive?"
- •"How do I extract the value from an enum variant?"