-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Path::is_empty #39334
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
Path::is_empty #39334
Conversation
r? @aturon (rust_highfive has picked a reviewer for you, use r? to override) |
/// use std::path::Path; | ||
/// | ||
/// let path = Path::new(""); | ||
/// assert!(path.is_empty()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add ;
to the end of the line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is reason why it failed.
/// assert!(path.is_empty()) | ||
/// | ||
/// let path = Path::new("tmp"); | ||
/// assert!(!path.is_empty()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add ;
to the end of the line.
This was attempted before, for the record: #31877 |
@frewsxcv Noted. I'll just close this, then. |
While an empty path may not necessarily have semantic significance, because
PathBuf::new
returns an empty path, I feel that having this method is reasonable.I left out
len
because it could easily be confused for the number of components in the path. However,is_empty
seems useful and unambiguous.