Guys, in documentation I see section called "blanket implementation". Could anyone please tell me what is it?
Thanks
It is an implement of a trait either for all types, or for all types that match some condition. For example, the stdandard library has this impl:
impl<T> ToString for T
where
T: Display + ?Sized,
{ ... }
It is a blanket impl that implements ToString for all types that implement the Display trait.
Thanks, could you please tell me what ?Sized means?
Rust adds the T: Sized bound to all generics by default. Adding ?Sized removes that bound, allowing non-sized types too.
To clarify, the Sized trait means we know something's size at compile time. If you ever want to store something as a local variable the compiler needs to know how much space to set aside, and adding a ?Sized to your where clause relaxes that restriction.
See Dynamically Sized Types (DSTs) from The Nomicon if you want to go further down the ?Sized rabbit hole.