3 ms·
IIRC that's called "associated type" and is mostly used for shortening the function declaration inside the trait through using e.g. "Self::Output". E.g. the de
by Lev1a 7y ago
IIRC that's called "associated type" and is mostly used for shortening the function declaration inside the trait through using e.g. "Self::Output".
E.g. the definition of the real std::ops::Neg trait: https://doc.rust-lang.org/std/ops/trait.Neg.html https://doc.rust-lang.org/std/ops/trait.Neg.html
- steveklabnik 7y agoIt’s not about shortening things, it’s actually about semantics! Choosing to make something have a type parameter vs an associated type depends on what you’re trying to accomplish.