They are also needed to implement "trait aliases" where you create a trait that is constrained over multiple other traits (handy for reducing boilerplate and needed for multi-trait trait objects). Any is implemented for all T where T: 'static.into() when a matching From implementation exists) Into is implemented for all T where T: From (the reflexive implementation that allows you to call.From is implemented for all T (the identity implementation).You do not need to do anything to "opt-in" besides bringing the trait into scope. They are patently useful since it implements the trait for anything, in the entire ecosystem! If something satisfies the constraints, then it is able to take advantage of the implementation without needing to implement it themselves. Whereas for the normal "Trait Implementations" section, all those traits at least had some thought for the specific type in mind (usually). They are documented separately since they are applied without any particularity and may or may not be relevant to the type you're looking at. This does not cover things like impl Trait for Vec, which is a generic implementation but not a blanket implementation. They usually also have where clauses involved since it is very hard to do anything useful to an unconstrained T. A blanket implementation is an implementation of a trait on a generic parameter: impl Trait for T
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |