globwalk
globwalk copied to clipboard
`unwrap` is not that safe ...
Hello,
it seems that an unwrap considered safe, is panicking.
https://github.com/Gilnaa/globwalk/blob/8973fa2bc560be54c91448131238fa50d56ee121/src/lib.rs#L381
thread '<unnamed>' panicked at /home/..../index.crates.io-6f17d22bba15001f/globwalk-0.9.1/src/lib.rs:381:78:
called `Result::unwrap()` on an `Err` value: StripPrefixError(())
seems like the panic happen when those kind of values arrive in the strip_prefix function :
#[cfg(test)]
mod tests {
use std::path::PathBuf;
#[test]
fn a_test() {
let path = PathBuf::from("./plop.file");
path.strip_prefix("plop.file").unwrap();
}
}
called `Result::unwrap()` on an `Err` value: StripPrefixError(())
stack backtrace:
0: rust_begin_unwind
1: core::panicking::panic_fmt
2: core::result::unwrap_failed
What invocation of globwalk did you use to get this? What crate versions do you have in your lockfile?
lock file is on the latest version
[[package]]
name = "globwalk"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0bf760ebf69878d9fd8f110c89703d90ce35095324d1f1edcb595c63945ee757"
dependencies = [
"bitflags 2.5.0",
"ignore",
"walkdir",
]
a failing case would be as simple as this one :
#[cfg(test)]
mod tests {
#[test]
fn test() -> anyhow::Result<()> {
let all_files = globwalk::GlobWalkerBuilder::from_patterns("./src", &[""])
.build()?
.filter_map(Result::ok);
for file in all_files {
dbg!(file);
}
Ok(())
}
}