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

Function unpack_pascal

crates/vm/src/buffer.rs:705–715  ·  view source on GitHub ↗
(vm: &VirtualMachine, data: &[u8])

Source from the content-addressed store, hash-verified

703}
704
705fn unpack_pascal(vm: &VirtualMachine, data: &[u8]) -> PyObjectRef {
706 let (&len, data) = match data.split_first() {
707 Some(x) => x,
708 None => {
709 // cpython throws an internal SystemError here
710 return vm.ctx.new_bytes(vec![]).into();
711 }
712 };
713 let len = core::cmp::min(len as usize, data.len());
714 vm.ctx.new_bytes(data[..len].to_vec()).into()
715}
716
717// XXX: are those functions expected to be placed here?
718pub fn struct_error_type(vm: &VirtualMachine) -> &'static PyTypeRef {

Callers 1

unpackMethod · 0.85

Calls 4

minFunction · 0.85
to_vecMethod · 0.80
new_bytesMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected