-
Notifications
You must be signed in to change notification settings - Fork 24
Closed as not planned
Description
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);kennytmKisaragiEffective
Metadata
Metadata
Assignees
Labels
No labels