-
Notifications
You must be signed in to change notification settings - Fork 13k
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
PathBuf
does not have is_empty()
#30259
Comments
Related to rust-lang#30259 Rebase of rust-lang#30623
Implemented in #31877. |
Original issue requesting this feature: rust-lang#30259 Originally implemented in rust-lang#30623 but that pull request when stale. It was rebased in rust-lang#31231, but the `Path` changes got lost as the focus shifted towards `OsString` and `OsStr`. An RFC (rust-lang/rfcs#1497) was briefly opened, since I didn't know if this functionality needed an RFC, but @alexcrichton clarified in the RFC issue I linked that this is not the case.
Now that #31608 landed, getting the length and emptiness is pretty easy: let _ = some_path.as_os_str().len();
let _ = some_path.as_os_str().is_empty(); Does anyone think it's still worth it to add the |
I don't see why you'd want |
Closing due to the reasons outlined in this comment |
@alexcrichton My use-case was completely different: using |
Yeah for now you probably want to take a look at |
It is possible to create an empty
PathBuf
:— yet
PathBuf
has nois_empty()
function (nor, apparently, doPath
orOsStr
orOsString
).This seems inconsistent.
Of course, there are several ways around this (
p == PathBuf::new()
,p.to_str().map_or(true, |s| s.is_empty())
, wrapping withOption
), but having a simple way to check this would be nice.The text was updated successfully, but these errors were encountered: