diff --git a/wutil-rs/src/find_file.rs b/wutil-rs/src/find_file.rs index bcc4447d..9e86d0f7 100644 --- a/wutil-rs/src/find_file.rs +++ b/wutil-rs/src/find_file.rs @@ -35,9 +35,7 @@ use std::{ /// Tries to interpret `s` as a UTF-8 path. Returns `None` if decoding `s` /// fails. pub fn path_from_cstr(s: &CStr) -> Option { - String::from_utf8(s.to_bytes().iter().copied().collect()) - .ok() - .map(|p| PathBuf::from(p)) + s.to_str().ok().map(PathBuf::from) } /// If `file` is an absolute path can be opened, returns that path. Paths