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

Method parse

crates/vm/src/stdlib/_io.rs:2571–2591  ·  view source on GitHub ↗
(cookie: &BigInt)

Source from the content-addressed store, hash-verified

2569 const BYTE_LEN: usize = Self::BYTES_TO_SKIP_OFF + 4;
2570
2571 fn parse(cookie: &BigInt) -> Option<Self> {
2572 let (_, mut buf) = cookie.to_bytes_le();
2573 if buf.len() > Self::BYTE_LEN {
2574 return None;
2575 }
2576 buf.resize(Self::BYTE_LEN, 0);
2577 let buf: &[u8; Self::BYTE_LEN] = buf.as_array()?;
2578 macro_rules! get_field {
2579 ($t:ty, $off:ident) => {
2580 <$t>::from_ne_bytes(*buf[Self::$off..].first_chunk().unwrap())
2581 };
2582 }
2583 Some(Self {
2584 start_pos: get_field!(Offset, START_POS_OFF),
2585 dec_flags: get_field!(i32, DEC_FLAGS_OFF),
2586 bytes_to_feed: get_field!(i32, BYTES_TO_FEED_OFF),
2587 chars_to_skip: get_field!(i32, CHARS_TO_SKIP_OFF),
2588 need_eof: get_field!(u8, NEED_EOF_OFF) != 0,
2589 bytes_to_skip: get_field!(i32, BYTES_TO_SKIP_OFF),
2590 })
2591 }
2592
2593 fn build(&self) -> BigInt {
2594 let mut buf = [0; Self::BYTE_LEN];

Callers 1

ast_from_objectMethod · 0.45

Calls 3

SomeClass · 0.50
lenMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected