-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-ioArea: `std::io`, `std::fs`, `std::net` and `std::path`Area: `std::io`, `std::fs`, `std::net` and `std::path`C-bugCategory: This is a bug.Category: This is a bug.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Description
The following code runs without any errors:
let mut p = Path::new("myfile.pdf").to_owned();
p.set_extension("txt/doc");
println!("{:?} {}", p, p.components().count());
// "myfile.txt/doc" 2
I'm not sure what I expected this to do. Maybe panic? I would also have been ok with short-circuiting and returning false. But succeeding feels weird to me.
The set_file_name
method has a similar problem. There's no return value on that one, so panicking might be the only option, if we don't like allowing slashes in the new filename.
rkjnsn and sras
Metadata
Metadata
Assignees
Labels
A-ioArea: `std::io`, `std::fs`, `std::net` and `std::path`Area: `std::io`, `std::fs`, `std::net` and `std::path`C-bugCategory: This is a bug.Category: This is a bug.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.