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

Function pack_pascal

crates/vm/src/buffer.rs:680–691  ·  view source on GitHub ↗
(vm: &VirtualMachine, arg: PyObjectRef, buf: &mut [u8])

Source from the content-addressed store, hash-verified

678}
679
680fn pack_pascal(vm: &VirtualMachine, arg: PyObjectRef, buf: &mut [u8]) -> PyResult<()> {
681 if buf.is_empty() {
682 return Ok(());
683 }
684 let b = ArgBytesLike::try_from_object(vm, arg)?;
685 b.with_ref(|data| {
686 let string_length = core::cmp::min(core::cmp::min(data.len(), 255), buf.len() - 1);
687 buf[0] = string_length as u8;
688 write_string(&mut buf[1..], data);
689 });
690 Ok(())
691}
692
693fn write_string(buf: &mut [u8], data: &[u8]) {
694 let len_from_data = core::cmp::min(data.len(), buf.len());

Callers 1

pack_intoMethod · 0.85

Calls 5

minFunction · 0.85
write_stringFunction · 0.85
with_refMethod · 0.80
is_emptyMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected