Cairo Traits
Overview
Guide how to define and implement traits in Cairo, including bounds and default behavior.
Quick Use
- •Read
references/traits.mdbefore answering. - •Show a minimal
traitplusimpl Name of Trait<T>example. - •Remind users to bring traits into scope to call trait methods.
Response Checklist
- •Define trait methods with signatures only, unless providing defaults.
- •Implement with
impl ImplName of Trait<Type> { ... }. - •Include trait bounds when generics need specific behavior.
Example Requests
- •"How do I implement a trait for a struct in Cairo?"
- •"Why can't I call a trait method even though impl exists?"
- •"Can a trait provide default method bodies?"