forked from vitrine/wmaker
Simplify path_from_cstr substantially (h/t cross).
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user