-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Clarify shared file handler behavior of File::try_clone. #47958
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
r? @aidanhs (rust_highfive has picked a reviewer for you, use r? to override) |
2f2bfd0
to
687c30a
Compare
src/libstd/fs.rs
Outdated
/// references. Both handles will read and write with the same cursor | ||
/// position. | ||
/// Modifying one `File` (e.g. reading, writing, seeking) will result in the | ||
/// underlying file handle of the other `File` also adjusting. |
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.
not a big fan of my wording here or in the previous section. lemme know if y'all have better suggestions
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.
Maybe something along the lines of:
This means that both
File
instance shares the same cursor; reads, writes and seeks will affect both instances simultaneously.
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.
Thanks for the suggestion! Latest force push incorporates some of that wording
I just realized this could be a bad footgun for someone using a cloned handle with |
687c30a
to
d597da3
Compare
@abonander I think that might be a good idea. Any suggestions on how to word this? |
Something like Note:
|
We already have a warning about a similar footgun with |
Okay so it sounds like we might want to open a separate issue for that then? What do you think? |
@bors r+ rollup This looks good to me, and it sounds like the bufreader thing may need more discussion elsewhere. |
📌 Commit d597da3 has been approved by |
💡 This pull request was already approved, no need to approve it again.
|
📌 Commit d597da3 has been approved by |
Clarify shared file handler behavior of File::try_clone. Fixes rust-lang#46578.
Clarify shared file handler behavior of File::try_clone. Fixes rust-lang#46578.
Clarify shared file handler behavior of File::try_clone. Fixes rust-lang#46578.
Fixes #46578.