...
Code Block | ||
---|---|---|
| ||
use std::borrow::Cow; trait CustomInto<T> { fn custom_into(self) -> T; } impl<'a> CustomInto<Cow<'a, str>> for &'a str { fn custom_into(self) -> Cow<'a, str> { Cow::Borrowed(self) } } fn main(){ let _cow = "hello there".custom_into(); } |
In this code, Note how the implementation is for the ref string slice type, not the primitive string slice type.
...