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

Function pack_char

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

Source from the content-addressed store, hash-verified

661}
662
663fn pack_char(vm: &VirtualMachine, arg: PyObjectRef, data: &mut [u8]) -> PyResult<()> {
664 let v = PyBytesRef::try_from_object(vm, arg)?;
665 let ch = *v
666 .as_bytes()
667 .iter()
668 .exactly_one()
669 .map_err(|_| new_struct_error(vm, "char format requires a bytes object of length 1"))?;
670 data[0] = ch;
671 Ok(())
672}
673
674fn pack_string(vm: &VirtualMachine, arg: PyObjectRef, buf: &mut [u8]) -> PyResult<()> {
675 let b = ArgBytesLike::try_from_object(vm, arg)?;

Callers

nothing calls this directly

Calls 3

new_struct_errorFunction · 0.85
iterMethod · 0.45
as_bytesMethod · 0.45

Tested by

no test coverage detected