MCPcopy Create free account
hub / github.com/Work-Fisher/code-claw / parse_number

Method parse_number

claw-code/rust/crates/runtime/src/json.rs:269–287  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

267 }
268
269 fn parse_number(&mut self) -> Result<i64, JsonError> {
270 let mut value = String::new();
271 if self.try_consume('-') {
272 value.push('-');
273 }
274
275 while let Some(ch @ '0'..='9') = self.peek() {
276 value.push(ch);
277 self.index += 1;
278 }
279
280 if value.is_empty() || value == "-" {
281 return Err(JsonError::new("invalid number"));
282 }
283
284 value
285 .parse::<i64>()
286 .map_err(|_| JsonError::new("number out of range"))
287 }
288
289 fn expect(&mut self, expected: char) -> Result<(), JsonError> {
290 match self.next() {

Callers 1

parse_valueMethod · 0.80

Calls 3

try_consumeMethod · 0.80
peekMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected