You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Similarly to Rust, we want to add the notion of associated items to Cairo. In particular, associated types, which are a blocker for writing iterators the "right way" (and thus a blocker to nice for loops):
pub trait Iterator<C> {
type Item;
fn next(ref self: C) -> Option<Self::Item>;
}
The next in the line of associated items to be implemented is associated consts. For a natural usecase example, consider game characters where each character has a specific amount of hit points. You don't want the character type to be generic on the hitpoints since this would allow instantiating characters with the wrong values. Instead, with associated consts, you can define the following trait:
Similarly to Rust, we want to add the notion of associated items to Cairo. In particular, associated types, which are a blocker for writing iterators the "right way" (and thus a blocker to nice for loops):
The next in the line of associated items to be implemented is associated consts. For a natural usecase example, consider game characters where each character has a specific amount of hit points. You don't want the character type to be generic on the hitpoints since this would allow instantiating characters with the wrong values. Instead, with associated consts, you can define the following trait:
The text was updated successfully, but these errors were encountered: