-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Add documentation to point to File::open
or OpenOptions::open
instead of is_file
to check read/write possibility
#73243
Conversation
r? @cramertj (rust_highfive has picked a reviewer for you, use r? to override) |
@rustbot modify labels: T-doc, T-libs, C-enhancement |
r? @Amanieu |
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.
The formatting, grammar, etc, of this all look good to me. I'll let libs decide if they want to add this or not.
You are forgetting about unix sockets which are another type of file that you can't just read/write bytes to. The proper way of checking whether you can read/write bytes to a file is to try opening it. This will fail for directories, symlinks (if open is called with |
@Amanieu good catch ! I changed the text to point to |
!is_dir
instead of is_file
forFile::open
or OpenOptions::open
instead of is_file
to check read/write possibility
@bors r+ rollup |
📌 Commit 8e8c54a has been approved by |
…Amanieu Add documentation to point to `File::open` or `OpenOptions::open` instead of `is_file` to check read/write possibility Fixes rust-lang#64170. This adds documentation to point user towards `!is_dir` instead of `is_file` when all they want to is read from a source. I ran `rg "fn is_file\("` to find all `is_file` methods, I hope I did not miss one.
…Amanieu Add documentation to point to `File::open` or `OpenOptions::open` instead of `is_file` to check read/write possibility Fixes rust-lang#64170. This adds documentation to point user towards `!is_dir` instead of `is_file` when all they want to is read from a source. I ran `rg "fn is_file\("` to find all `is_file` methods, I hope I did not miss one.
…Amanieu Add documentation to point to `File::open` or `OpenOptions::open` instead of `is_file` to check read/write possibility Fixes rust-lang#64170. This adds documentation to point user towards `!is_dir` instead of `is_file` when all they want to is read from a source. I ran `rg "fn is_file\("` to find all `is_file` methods, I hope I did not miss one.
…arth Rollup of 10 pull requests Successful merges: - rust-lang#72796 (MIR sanity check: validate types on assignment) - rust-lang#73243 (Add documentation to point to `File::open` or `OpenOptions::open` instead of `is_file` to check read/write possibility) - rust-lang#73525 (Prepare for LLVM 11) - rust-lang#73672 (Adds a clearer message for when the async keyword is missing from a f…) - rust-lang#73708 (Explain move errors that occur due to method calls involving `self` (take two)) - rust-lang#73758 (improper_ctypes: fix remaining `Reveal:All`) - rust-lang#73763 (errors: use `-Z terminal-width` in JSON emitter) - rust-lang#73796 (replace more `DefId`s with `LocalDefId`) - rust-lang#73797 (fix typo in self-profile.md) - rust-lang#73809 (Add links to fs::DirEntry::metadata) Failed merges: r? @ghost
Fixes #64170.
This adds documentation to point user towards
!is_dir
instead ofis_file
when all they want to is read from a source.I ran
rg "fn is_file\("
to find allis_file
methods, I hope I did not miss one.