In Rust 1.1, std::fs::PathExt marked unstable; How to check for a file or directory?
std::fs::PathExt
Is there a canonical solution for this, or do I need to read the source std::fs::PathExt ?
Maybe a box that provides this functionality?
PathExt - simple wrappers around std::fs::metadata ; if the path does not exist, metadata will return an error, therefore PathExt.exists() is a simple metadata(self).is_ok() .
PathExt
std::fs::metadata
metadata
PathExt.exists()
metadata(self).is_ok()
Usually you should use is_file or is_dir ; they correspond to metadata(self).map(|m| m.Β«is_file or is_dirΒ»()).unwrap_or(false) .
is_file
is_dir
metadata(self).map(|m| m.Β«is_file or is_dirΒ»()).unwrap_or(false)