Simplify path_from_cstr substantially (h/t cross).

This commit is contained in:
2025-10-23 14:46:56 -04:00
parent f3961ba66f
commit cf588d6e27
+1 -3
View File
@@ -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<PathBuf> {
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