Path::parent returns Some("") for relative paths like foo.txt, but read_dir throws an error when given "", so code like if let Some(parent) = path.parent() { std::fs::read_dir(parent) } fails for files in the working directory.
Additionally, calling read_dir on a relative file without a ./ prefix returns file paths without ./ prefixes, but there is no way to achieve similar behavior for the working directory because read_dir("") throws an error. read_dir(".") returns file paths with ./ prefixes and is not a solution.
This was tested on Unix, and may be Unix-specific, but I lack a Windows machine to easily test against.
Path::parentreturnsSome("")for relative paths likefoo.txt, butread_dirthrows an error when given"", so code likeif let Some(parent) = path.parent() { std::fs::read_dir(parent) }fails for files in the working directory.Additionally, calling
read_diron a relative file without a./prefix returns file paths without./prefixes, but there is no way to achieve similar behavior for the working directory becauseread_dir("")throws an error.read_dir(".")returns file paths with./prefixes and is not a solution.This was tested on Unix, and may be Unix-specific, but I lack a Windows machine to easily test against.