It might be GenericCow<str>
(edit: see example), but …
Edit: Also GenericCow<str>
implies Borrow<str>
, which is stricter than AsRef<str>
. Thus GenericCow
is the corresponding match for Borrow
instead of AsRef
.
Edit #2: On the other hand, Cow<'_, str>
and GenericCow<str>
are more generic as they support borrowing while you only wanted to require ownership in all cases. Thus Cow
/GenericCow
are different concepts: 1. borrowing (where Eq
, Ord
, and Hash
behave consistent) instead of cheap conversion (where Eq
, Ord
, and Hash
do not have to behave consistent), and 2. supporting both directions (either to a reference or to an owned value, while you only want an owned value).
I would say then the equivalent to AsRef<str>
is Into<String>
, like you said. Note: Both are in std::convert
.
I think it's this.
This is sometimes more lax, sometimes more strict (I think). More lax because It will accept everything with a string representation due to impl<T: ?Sized> ToString for T where T: Display + ?Sized
, see implementators of ToString
. More strict because it will not accept anything everything that is Into<String>
, right?
This clones unnecessarily. See also this long thread.