Skip to content
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

Clarify semantics of File::try_clone() #46578

Closed
abonander opened this issue Dec 8, 2017 · 5 comments
Closed

Clarify semantics of File::try_clone() #46578

abonander opened this issue Dec 8, 2017 · 5 comments
Assignees
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools P-medium Medium priority

Comments

@abonander
Copy link
Contributor

abonander commented Dec 8, 2017

File::try_clone() could be clearer about how the duplicated file cursors behave. It currently says:

The returned File is a reference to the same state that this object references. Both handles will read and write with the same cursor position.

I think it could be much clearer about how reads, writes, and seeks will affect both handles.

@bstrie bstrie added A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools P-medium Medium priority labels Dec 8, 2017
@bstrie
Copy link
Contributor

bstrie commented Dec 8, 2017

Tagging P-medium at @Havvy 's request.

@Havvy
Copy link
Contributor

Havvy commented Dec 8, 2017

Having an example where it shows this behaviour would also be helpful. E.g. try_clone the File, mutate the internal state in the clone, and then show that the original has also been mutated. Such as a file with contents "123456". Read to "3" in the clone, and then show that the next read of a character gets you "4".

The semantics that a separate File can change the first one should also probably be mentioned in the struct level documentation, since that's quite important to know even if you never call the method yourself.

@frewsxcv
Copy link
Member

frewsxcv commented Dec 8, 2017

This is very similar to #45536, if not a duplicate

@Havvy
Copy link
Contributor

Havvy commented Dec 8, 2017

Not a dupe. #45536 is about what the error case is. This is about being more explicit about the shared cursor position in the success case. Very related though.

@frewsxcv
Copy link
Member

frewsxcv commented Feb 2, 2018

I opened a PR for this: #47958

frewsxcv added a commit to frewsxcv/rust that referenced this issue Feb 3, 2018
kennytm added a commit to kennytm/rust that referenced this issue Feb 3, 2018
Clarify shared file handler behavior of File::try_clone.

Fixes rust-lang#46578.
kennytm added a commit to kennytm/rust that referenced this issue Feb 4, 2018
Clarify shared file handler behavior of File::try_clone.

Fixes rust-lang#46578.
kennytm added a commit to kennytm/rust that referenced this issue Feb 4, 2018
Clarify shared file handler behavior of File::try_clone.

Fixes rust-lang#46578.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools P-medium Medium priority
Projects
None yet
Development

No branches or pull requests

4 participants