Closed
Description
The current documentation for std::path::Path::starts_with
does not specify that it uses components as base
. For example as described in the current documentation I expected to be able to use characters as base
to find hidden files/directories as such:
fn is_dot(dir: &PathBuf) -> bool {
if dir.starts_with(".") {
return true;
} else {
return false
}
}
fn main() {
let path = PathBuf::from("/home/user/.dotfile");
let rel_path = path.relative_from("/home/user").unwrap();
println!("{}", path.display());
println!("{}", rel_path.display());
if is_dot(&PathBuf::from(rel_path)) {
println!("{} is dot", rel_path.display());
}
}
As described in the documentation I expected is_dot(&PathBuf::from(rel_path))
to be evaluated as true when it does not
Metadata
Metadata
Assignees
Labels
No labels