Skip to content

Seek needs finalization of its API #10432

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

Closed
alexcrichton opened this issue Nov 11, 2013 · 3 comments · Fixed by #12204
Closed

Seek needs finalization of its API #10432

alexcrichton opened this issue Nov 11, 2013 · 3 comments · Fixed by #12204
Milestone

Comments

@alexcrichton
Copy link
Member

There is currently an XXX on the seek trait asking a question about what to do about seeks out of bounds of the current file. Additionally, this leads to the fail!()-ing implementations of Seek on MemReader, BufReader, and BufWriter. MemWriter currently has an implementation that fills with 0s when you seek beyond the end and then perform a write.

In my opinion, the semantics should be defined as:

  • If you seek to a negative offset, return an error immediately (from the call to seek).
  • If you seek within "the file", we're all good
  • If you seek beyond the end of "the file", then it's a valid operation and it's left up to the implementation to decide what to do afterwards. For example, a writer may decide to fill the intermediate gap with 0s. On the other hand, a reader would return an EndOfFile error on the next read (etc.).

This behavior follows what lseek + read + write appear to do. Regardless, we need to decide on this for 1.0. Nominating.

@alexcrichton
Copy link
Member Author

Additionally, tell can fail right now, but it would be super awesome if it didn't have to. Do we actually prevent all of the error cases?

@pnkfelix
Copy link
Member

Accepted for P-backcompat-libs

@emberian
Copy link
Member

Someone in IRC also pointed out that seek/tell should be split into their own traits, with Seek probably inheriting from Tell. I don't remember the exact argument.

bors added a commit that referenced this issue Feb 12, 2014
This adopts the rules posted in #10432:

1. If a seek position is negative, then an error is generated
2. Seeks beyond the end-of-file are allowed. Future writes will fill the gap
   with data and future reads will return errors.
3. Seeks within the bounds of a file are fine.

Closes #10432
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 25, 2022
fix: Fall back to parameter definitions on error types in signature help

Fixes  rust-lang#10432
flip1995 pushed a commit to flip1995/rust that referenced this issue May 5, 2023
New lint: detect `if` expressions with simple boolean assignments to the same target

Closes rust-lang#10430

changelog: [`needless_bool_assign`] new lint to detect simple boolean assignment to the same target in `if` branches
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants