|
|
@@ -37,15 +37,11 @@ pub(crate) fn decode_utf8_lossy(input: Cow<[u8]>) -> Cow<str> {
|
|
|
|
|
|
// Given we know the original input bytes are valid UTF-8,
|
|
|
// and we have ownership of those bytes, we re-use them and
|
|
|
- // return a Cow::Owned here. Ideally we'd put our return statement
|
|
|
- // right below this line, but to support the old lexically scoped
|
|
|
- // borrow checker the return must be moved to outside the match
|
|
|
- // statement.
|
|
|
+ // return a Cow::Owned here.
|
|
|
+ Cow::Owned(unsafe { String::from_utf8_unchecked(bytes) })
|
|
|
}
|
|
|
- Cow::Owned(s) => return Cow::Owned(s),
|
|
|
+ Cow::Owned(s) => Cow::Owned(s),
|
|
|
}
|
|
|
-
|
|
|
- Cow::Owned(unsafe { String::from_utf8_unchecked(bytes) })
|
|
|
}
|
|
|
}
|
|
|
}
|