diff --git a/src/lib.rs b/src/lib.rs index 8428a9a..b018ada 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -943,8 +943,13 @@ fn fill_todo( match dirs { Ok(mut children) => { if options.require_literal_leading_dot { - children - .retain(|x| !x.file_name().unwrap().to_str().unwrap().starts_with('.')); + children.retain(|x| { + !x.file_name() + .unwrap() + .to_str() + // FIXME (#9639): This needs to handle non-utf8 paths + .is_none_or(|s| s.starts_with('.')) + }); } children.sort_by(|p1, p2| p2.file_name().cmp(&p1.file_name())); todo.extend(children.into_iter().map(|x| Ok((x, idx)))); diff --git a/tests/glob-std.rs b/tests/glob-std.rs index ba12701..672a8ad 100644 --- a/tests/glob-std.rs +++ b/tests/glob-std.rs @@ -18,12 +18,15 @@ extern crate tempdir; use glob::{glob, glob_with}; use std::env; use std::fs; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use tempdir::TempDir; #[test] fn main() { - fn mk_file(path: &str, directory: bool) { + fn mk_file
(path: P, directory: bool)
+ where
+ P: AsRef