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.
The following code runs without any errors:
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_namemethod 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.