From cf588d6e278a213732b0edb5c8f19415eca784cf Mon Sep 17 00:00:00 2001 From: Stu Black Date: Fri, 17 Oct 2025 11:00:48 -0400 Subject: [PATCH] Simplify `path_from_cstr` substantially (h/t cross). --- wutil-rs/src/find_file.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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