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

Method to_path_buf

crates/vm/src/function/fspath.rs:107–113  ·  view source on GitHub ↗
(&self, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

105 }
106
107 pub fn to_path_buf(&self, vm: &VirtualMachine) -> PyResult<PathBuf> {
108 let path = match self {
109 Self::Str(s) => PathBuf::from(vm.fsencode(s)?.as_ref() as &OsStr),
110 Self::Bytes(b) => PathBuf::from(Self::bytes_as_os_str(b, vm)?),
111 };
112 Ok(path)
113 }
114
115 pub fn to_cstring(&self, vm: &VirtualMachine) -> PyResult<alloc::ffi::CString> {
116 alloc::ffi::CString::new(self.as_bytes()).map_err(|e| e.into_pyexception(vm))

Callers 7

load_verify_locationsMethod · 0.80
load_dh_paramsMethod · 0.80
load_cert_chainMethod · 0.80
_test_decode_certFunction · 0.80
search_upFunction · 0.80
detect_venvFunction · 0.80
check_dirFunction · 0.80

Calls 3

fsencodeMethod · 0.80
bytes_as_os_strFunction · 0.50
as_refMethod · 0.45

Tested by

no test coverage detected