diff options
| author | bors <bors@rust-lang.org> | 2023-02-12 11:09:06 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-02-12 11:09:06 +0000 |
| commit | adb4bfd25d3c1190b0e7433ef945221d8aeea427 (patch) | |
| tree | 506089b876ecb35668ca29ec5d0fcc122955c3fe /library/alloc/src | |
| parent | 51cb5614dde163c53aab73e2dc33bb9f388b50a8 (diff) | |
| parent | 76e216f29b44322b52c49d8c56f20763beb271b5 (diff) | |
| download | rust-adb4bfd25d3c1190b0e7433ef945221d8aeea427.tar.gz rust-adb4bfd25d3c1190b0e7433ef945221d8aeea427.zip | |
Auto merge of #105671 - lukas-code:depreciate-char, r=scottmcm
Use associated items of `char` instead of freestanding items in `core::char`
The associated functions and constants on `char` have been stable since 1.52 and the freestanding items have soft-deprecated since 1.62 (https://github.com/rust-lang/rust/pull/95566). This PR ~~marks them as "deprecated in future", similar to the integer and floating point modules (`core::{i32, f32}` etc)~~ replaces all uses of `core::char::*` with `char::*` to prepare for future deprecation of `core::char::*`.
Diffstat (limited to 'library/alloc/src')
| -rw-r--r-- | library/alloc/src/string.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index 75659188515..2b843647dd5 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -42,8 +42,6 @@ #![stable(feature = "rust1", since = "1.0.0")] -#[cfg(not(no_global_oom_handling))] -use core::char::{decode_utf16, REPLACEMENT_CHARACTER}; use core::error::Error; use core::fmt; use core::hash; @@ -683,7 +681,7 @@ impl String { // This isn't done via collect::<Result<_, _>>() for performance reasons. // FIXME: the function can be simplified again when #48994 is closed. let mut ret = String::with_capacity(v.len()); - for c in decode_utf16(v.iter().cloned()) { + for c in char::decode_utf16(v.iter().cloned()) { if let Ok(c) = c { ret.push(c); } else { @@ -722,7 +720,9 @@ impl String { #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn from_utf16_lossy(v: &[u16]) -> String { - decode_utf16(v.iter().cloned()).map(|r| r.unwrap_or(REPLACEMENT_CHARACTER)).collect() + char::decode_utf16(v.iter().cloned()) + .map(|r| r.unwrap_or(char::REPLACEMENT_CHARACTER)) + .collect() } /// Decomposes a `String` into its raw components. |
