The following methods were stabilized in Rust 1.87.0:
The only difference between these methods and core::str::from_utf8* such as core::str::from_utf8 is the namespace (str primitive type or core::str module). I don't think there's any reason to use the traditional core::str::from_utf8* instead of <str>::from_utf8* if the MSRV is 1.87.0.
So I propose adding the deprecated attribute to core::str::from_utf8* as follows:
// `library/core/src/str/converts.rs`
#[deprecated(since = "1.87.0", note = "use `<str>::from_utf8` instead")]
pub const fn from_utf8(v: &[u8]) -> Result<&str, Utf8Error> {
...
}
Replacing core::str::from_utf8* with <str>::from_utf8* is as simple as:
// some bytes, in a vector
let sparkle_heart = vec![240, 159, 146, 150];
// We can use the ? (try) operator to check if the bytes are valid
-let sparkle_heart = core::str::from_utf8(&sparkle_heart)?;
+let sparkle_heart = str::from_utf8(&sparkle_heart)?;
assert_eq!("💖", sparkle_heart);
The following methods were stabilized in Rust 1.87.0:
<str>::from_utf8<str>::from_utf8_mut<str>::from_utf8_unchecked<str>::from_utf8_unchecked_mutThe only difference between these methods and
core::str::from_utf8*such ascore::str::from_utf8is the namespace (strprimitive type orcore::strmodule). I don't think there's any reason to use the traditionalcore::str::from_utf8*instead of<str>::from_utf8*if the MSRV is 1.87.0.So I propose adding the
deprecatedattribute tocore::str::from_utf8*as follows:Replacing
core::str::from_utf8*with<str>::from_utf8*is as simple as: