Skip to content

Commit 665114e

Browse files
committed
Use std::str::from_utf8 consistently
The `str::from_utf8` method on the `str` type was only stabilized in Rust 1.87. It looks like the method is used via this path accidentally in some places, because it is used via `std::str::from_utf8` in most other places (which has been available since Rust 1.0).
1 parent c359a00 commit 665114e

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/escape.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2120,12 +2120,12 @@ mod normalization {
21202120
fn utf8_0xc2() {
21212121
// All possible characters encoded in 2 bytes in UTF-8 which first byte is 0xC2 (0b11000010)
21222122
// Second byte follows the pattern 10xxxxxx
2123-
let first = str::from_utf8(&[0b11000010, 0b10000000])
2123+
let first = std::str::from_utf8(&[0b11000010, 0b10000000])
21242124
.unwrap()
21252125
.chars()
21262126
.next()
21272127
.unwrap();
2128-
let last = str::from_utf8(&[0b11000010, 0b10111111])
2128+
let last = std::str::from_utf8(&[0b11000010, 0b10111111])
21292129
.unwrap()
21302130
.chars()
21312131
.next()
@@ -2134,7 +2134,7 @@ mod normalization {
21342134
for ch in first..=last {
21352135
ch.encode_utf8(&mut utf8);
21362136
let description = format!("UTF-8 [{:02x} {:02x}] = `{}`", utf8[0], utf8[1], ch);
2137-
let input = str::from_utf8(&utf8).expect(&description);
2137+
let input = std::str::from_utf8(&utf8).expect(&description);
21382138

21392139
dbg!((input, &description));
21402140
if ch == '\u{0085}' {
@@ -2150,12 +2150,12 @@ mod normalization {
21502150
fn utf8_0x0d_0xc2() {
21512151
// All possible characters encoded in 2 bytes in UTF-8 which first byte is 0xC2 (0b11000010)
21522152
// Second byte follows the pattern 10xxxxxx
2153-
let first = str::from_utf8(&[0b11000010, 0b10000000])
2153+
let first = std::str::from_utf8(&[0b11000010, 0b10000000])
21542154
.unwrap()
21552155
.chars()
21562156
.next()
21572157
.unwrap();
2158-
let last = str::from_utf8(&[0b11000010, 0b10111111])
2158+
let last = std::str::from_utf8(&[0b11000010, 0b10111111])
21592159
.unwrap()
21602160
.chars()
21612161
.next()
@@ -2167,7 +2167,7 @@ mod normalization {
21672167
"UTF-8 [{:02x} {:02x} {:02x}] = `{}`",
21682168
utf8[0], utf8[1], utf8[2], ch
21692169
);
2170-
let input = str::from_utf8(&utf8).expect(&description);
2170+
let input = std::str::from_utf8(&utf8).expect(&description);
21712171

21722172
dbg!((input, &description));
21732173
if ch == '\u{0085}' {
@@ -2183,12 +2183,12 @@ mod normalization {
21832183
fn utf8_0xe2() {
21842184
// All possible characters encoded in 3 bytes in UTF-8 which first byte is 0xE2 (0b11100010)
21852185
// Second and third bytes follows the pattern 10xxxxxx
2186-
let first = str::from_utf8(&[0b11100010, 0b10000000, 0b10000000])
2186+
let first = std::str::from_utf8(&[0b11100010, 0b10000000, 0b10000000])
21872187
.unwrap()
21882188
.chars()
21892189
.next()
21902190
.unwrap();
2191-
let last = str::from_utf8(&[0b11100010, 0b10111111, 0b10111111])
2191+
let last = std::str::from_utf8(&[0b11100010, 0b10111111, 0b10111111])
21922192
.unwrap()
21932193
.chars()
21942194
.next()

src/se/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ where
167167
/// to_utf8_io_writer(&mut BufWriter::new(&mut buffer), &data).unwrap();
168168
///
169169
/// assert_eq!(
170-
/// str::from_utf8(&buffer).unwrap(),
170+
/// std::str::from_utf8(&buffer).unwrap(),
171171
/// // The root tag name is automatically deduced from the struct name
172172
/// // This will not work for other types or struct with #[serde(flatten)] fields
173173
/// "<Root attribute=\"attribute content\">\

0 commit comments

Comments
 (0)