MCPcopy Index your code
hub / github.com/RustPython/RustPython / json_escaped_char

Function json_escaped_char

crates/stdlib/src/json/machinery.rs:60–73  ·  view source on GitHub ↗
(c: u8)

Source from the content-addressed store, hash-verified

58
59#[inline(always)]
60fn json_escaped_char(c: u8) -> Option<&'static str> {
61 let bitset_value = NEEDS_ESCAPING_BITSET[(c / 64) as usize] & (1 << (c % 64));
62 if bitset_value == 0 {
63 None
64 } else {
65 Some(match c {
66 x if x < 0x20 => ESCAPE_CHARS[c as usize],
67 b'\\' => "\\\\",
68 b'\"' => "\\\"",
69 0x7F => "\\u007f",
70 _ => unreachable!(),
71 })
72 }
73}
74
75pub fn write_json_string<W: io::Write>(s: &str, ascii_only: bool, w: &mut W) -> io::Result<()> {
76 w.write_all(b"\"")?;

Callers 1

write_json_stringFunction · 0.85

Calls 1

SomeClass · 0.50

Tested by

no test coverage detected