-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Document what happens on failure in path ext is_file is_dir #42926
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
Conversation
This stemmed from a discussion in |
I'm not sure, but I also don't mind incrementalism.
👍 |
@Havvy ping on the "See also" |
Log from #rust-docs (with permission from @projektir and @GuillaumeGomez (a.k.a. imperio)
|
From the log, there's a bit of contention on what we want to do exactly. Do we want to treat the implementation as a black box and list out errors that could occur, or do we want to specifically point out that the errors coerced to I'm of the opinion we want to treat it as a black box, and the current PR reflects that. If we want to go the other way, I can word it as @projektir suggested towards the end of the IRC conversation. |
src/libstd/path.rs
Outdated
/// | ||
/// # See Also | ||
/// | ||
/// This is a convenience function that ignores errors. If you want to check errors, |
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.
"ignores errors" doesn't seem quite right: the function will return false
on errors, not ignore them.
I think API functions should be treated as black boxes and fs::metadata
not so explicitly tied in here. It should just be mentioned in the "See also".
Travis failed:
|
Interesting. These are comments with |
No. "# See also" is invalid rust code. You want to use "//". |
This is a comment though is it not? Or are "triple comments" executed? |
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.
i've got one tiny nit
src/libstd/path.rs
Outdated
/// # Examples | ||
/// | ||
/// ```no_run | ||
/// use std::path::Path; | ||
/// assert_eq!(Path::new("does_not_exist.txt").exists(), false); | ||
/// ``` | ||
/// # See Also |
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.
could you put an extra ///
above this please?
src/libstd/path.rs
Outdated
/// # Examples | ||
/// | ||
/// ```no_run | ||
/// use std::path::Path; | ||
/// assert_eq!(Path::new("./is_a_directory/").is_dir(), true); | ||
/// assert_eq!(Path::new("a_file.txt").is_dir(), false); | ||
/// # See Also |
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.
you need a triple backtick above this line, it's trying to execute
# See Also
as Rust code. the ///
has nothing to do with it, really.
A ///
below that backtick and above the /// # See Also
line would be good as well.
Oh my, I think this is actually mergable now. |
Just one last thing: please squash your commits. Once done, r+. |
@GuillaumeGomez Can't the merger squash? I thought that was supported by Github. |
Only the bot can merge, so the one who opened the PR has to do it. |
Squashed |
@bors r=GuillaumeGomez |
📌 Commit 0b7e49c has been approved by |
@bors rollup |
@bors: r+ |
📌 Commit a01c91c has been approved by |
Document what happens on failure in path ext is_file is_dir r? @steveklabnik Also, what other ways could there be an error that gets discarded and returns false? Should we list them all? Should we say that any errors trying to access the metadata at that path causes it to return false, even if there might be a file or directory there? Should I add a See also link to the original functions that do return Results?
r? @steveklabnik
Also, what other ways could there be an error that gets discarded and returns false? Should we list them all? Should we say that any errors trying to access the metadata at that path causes it to return false, even if there might be a file or directory there?
Should I add a See also link to the original functions that do return Results?