-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Path has no Default #78858
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Error: Label libs-impl can only be set by Rust team members Please let |
What does an empty path mean? Does it refer to the current directory? |
@jonas-schievink Currently, the empty path refers to (at least on Linux) a nonexistent file or directory. use std::path::Path;
fn main() {
let path = Path::new("");
println!("Empty string path");
println!("{}", path.display());
println!("Exists: {}", path.exists());
match path.canonicalize() {
Ok(p) => println!("{}", p.display()),
Err(e) => println!("error {}", e),
}
} |
Hmm, I'm not sure why it would be a good default then |
So the question shifts from "is |
If there's no clear default, then it probably should not have a Default impl at all, though maybe "." could work and be clear enough? Not sure. |
This issue seems to have been just me exploring why there is no
I thank everyone for their contributions and apologize for wasting time. |
Ran into this doing a pull request.
The
Path
struct has noimpl Default
documented, but a value ofPath::new("")
seems to be a good default in my mind. (Update: it is not, I have been corrected)This may be the incorrect way to ask for such a thing, but I would like to know why there is no
impl Default for Path
and whether there could be one in the near future.The text was updated successfully, but these errors were encountered: