]>
git.proxmox.com Git - rustc.git/blob - vendor/sysinfo/src/apple/utils.rs
1 // Take a look at the license at the top of the repository in the LICENSE file.
5 pub(crate) fn cstr_to_rust(c
: *const c_char
) -> Option
<String
> {
6 cstr_to_rust_with_size(c
, None
)
9 pub(crate) fn cstr_to_rust_with_size(c
: *const c_char
, size
: Option
<usize>) -> Option
<String
> {
13 let mut s
= match size
{
14 Some(len
) => Vec
::with_capacity(len
),
20 let value
= *c
.offset(i
) as u8;
27 String
::from_utf8(s
).ok()
31 #[cfg(target_os = "macos")]
32 pub(crate) fn vec_to_rust(buf
: Vec
<i8>) -> Option
<String
> {
35 .flat_map(|b
| if b
> 0 { Some(b as u8) }
else { None }
)