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

Method to_cstring

crates/vm/src/utils.rs:24–26  ·  view source on GitHub ↗
(&self, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

22
23pub trait ToCString: AsRef<Wtf8> {
24 fn to_cstring(&self, vm: &VirtualMachine) -> PyResult<alloc::ffi::CString> {
25 alloc::ffi::CString::new(self.as_ref().as_bytes()).map_err(|err| err.to_pyexception(vm))
26 }
27 fn ensure_no_nul(&self, vm: &VirtualMachine) -> PyResult<()> {
28 if self.as_ref().as_bytes().contains(&b'\0') {
29 Err(cstring_error(vm))

Callers

nothing calls this directly

Implementers 1

utils.rscrates/vm/src/utils.rs

Calls 4

newFunction · 0.85
as_bytesMethod · 0.45
as_refMethod · 0.45
to_pyexceptionMethod · 0.45

Tested by

no test coverage detected