from_utf8_lossy
's return value is a Cow
:
pub fn from_utf8_lossy(v: &[u8]) -> Cow<'_, str>
If you want to create a copy and transfer the ownership, into_owned()
of Cow
is specifically designed for that:
pub fn into_owned(self) -> <B as ToOwned>::Owned
Extracts the owned data.
Clones the data if it is not already owned.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…