MCPcopy Create free account
hub / github.com/Louisym/MiniCC / parse_unicode_escape

Method parse_unicode_escape

rust/crates/runtime/src/json.rs:216–227  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

214 }
215
216 fn parse_unicode_escape(&mut self) -> Result<char, JsonError> {
217 let mut value = 0_u32;
218 for _ in 0..4 {
219 let Some(ch) = self.next() else {
220 return Err(JsonError::new("unexpected end of input in unicode escape"));
221 };
222 value = (value << 4)
223 | ch.to_digit(16)
224 .ok_or_else(|| JsonError::new("invalid unicode escape"))?;
225 }
226 char::from_u32(value).ok_or_else(|| JsonError::new("invalid unicode scalar value"))
227 }
228
229 fn parse_array(&mut self) -> Result<JsonValue, JsonError> {
230 self.expect('[')?;

Callers 1

parse_escapeMethod · 0.80

Calls 1

nextMethod · 0.80

Tested by

no test coverage detected