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

Method from

crates/vm/src/stdlib/pwd.rs:38–58  ·  view source on GitHub ↗
(user: User)

Source from the content-addressed store, hash-verified

36
37 impl From<User> for PasswdData {
38 fn from(user: User) -> Self {
39 // this is just a pain...
40 let cstr_lossy = |s: alloc::ffi::CString| {
41 s.into_string()
42 .unwrap_or_else(|e| e.into_cstring().to_string_lossy().into_owned())
43 };
44 let pathbuf_lossy = |p: std::path::PathBuf| {
45 p.into_os_string()
46 .into_string()
47 .unwrap_or_else(|s| s.to_string_lossy().into_owned())
48 };
49 PasswdData {
50 pw_name: user.name,
51 pw_passwd: cstr_lossy(user.passwd),
52 pw_uid: user.uid.as_raw(),
53 pw_gid: user.gid.as_raw(),
54 pw_gecos: cstr_lossy(user.gecos),
55 pw_dir: pathbuf_lossy(user.dir),
56 pw_shell: pathbuf_lossy(user.shell),
57 }
58 }
59 }
60
61 #[pyfunction]

Callers

nothing calls this directly

Calls 5

into_stringMethod · 0.80
into_ownedMethod · 0.80
into_cstringMethod · 0.80
to_string_lossyMethod · 0.45
as_rawMethod · 0.45

Tested by

no test coverage detected