Skip to content

Commit 6e2c210

Browse files
committed
Touch up PR 1273
1 parent 623d9b4 commit 6e2c210

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/ser.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ use alloc::string::String;
77
use alloc::string::ToString;
88
use alloc::vec::Vec;
99
use core::fmt::{self, Display};
10+
use core::hint;
1011
use core::num::FpCategory;
12+
use core::str;
1113
use serde::ser::{self, Impossible, Serialize};
1214

1315
/// A structure for serializing Rust values into JSON.
@@ -2100,8 +2102,8 @@ where
21002102
bytes = rest;
21012103
i = 0;
21022104

2103-
// safety: string_run is a valid utf8 string, since we only split on ascii sequences
2104-
let string_run = unsafe { core::str::from_utf8_unchecked(string_run) };
2105+
// Safety: string_run is a valid utf8 string, since we only split on ascii sequences
2106+
let string_run = unsafe { str::from_utf8_unchecked(string_run) };
21052107
if !string_run.is_empty() {
21062108
tri!(formatter.write_string_fragment(writer, string_run));
21072109
}
@@ -2115,14 +2117,14 @@ where
21152117
self::QU => CharEscape::Quote,
21162118
self::BS => CharEscape::ReverseSolidus,
21172119
self::UU => CharEscape::AsciiControl(byte),
2118-
// safety: the escape table does not contain any other type of character.
2119-
_ => unsafe { core::hint::unreachable_unchecked() },
2120+
// Safety: the escape table does not contain any other type of character.
2121+
_ => unsafe { hint::unreachable_unchecked() },
21202122
};
21212123
tri!(formatter.write_char_escape(writer, char_escape));
21222124
}
21232125

2124-
// safety: bytes is a valid utf8 string, since we only split on ascii sequences
2125-
let string_run = unsafe { core::str::from_utf8_unchecked(bytes) };
2126+
// Safety: bytes is a valid utf8 string, since we only split on ascii sequences
2127+
let string_run = unsafe { str::from_utf8_unchecked(bytes) };
21262128
if string_run.is_empty() {
21272129
return Ok(());
21282130
}

0 commit comments

Comments
 (0)