Cairo Operator Overloading
Overview
Show how to overload operators by implementing the corresponding trait.
Quick Use
- •Read
references/operator-overloading.mdbefore answering. - •Use a concise example like
impl TypeAdd of Add<Type>. - •Emphasize that operator meaning should remain intuitive.
Response Checklist
- •Choose the correct trait (e.g.,
Add,Sub,Mul,Div,Rem,Neg). - •Implement the trait for the concrete RHS type (
Add<Other>orAdd<Self>). - •Return a new value with the expected semantics.
Example Requests
- •"How do I implement
+for a custom struct?" - •"Can I overload operators in Cairo?"