I want to make sure I'm reading the docs correctly in order to determine the types that implement a given trait. For example, looking at std::borrow::ToOwned - Rust I think it is telling me that it is implemented by str, Str, OsStr, Path, any array whose items implement Clone, and any type that implements Clone. Am I reading that correctly?
Note 1: But you can get a slice from an array anyway.
Note 2: I don't know why they're not showing up in the list of implementors, but arrays implement
Clone and some other traits too, as described in the link above. Probably something to do with how it's implemented and the recent advancement of
I see this in the docs for
impl<T> Borrow<T> for T where T: ?[Sized]
Does this mean that all the built-in scalar types implement
Borrow, including slices and tuples of those types?
It's broader than that. It means that all types implement
Borrow<Self>, regardless of how complicated they are or where they're defined. It doesn't mean, however, that all containers automatically get a borrow implementation for their contents.