Skip to content

doc: improve docs for std::io::Seek::rewind method #105596

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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions library/std/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1770,6 +1770,9 @@ pub trait Seek {
/// Rewind to the beginning of a stream.
///
/// This is a convenience method, equivalent to `seek(SeekFrom::Start(0))`.
/// Note that unlike `seek(SeekFrom::Start(0))`, this method does not return
/// the old offset and cannot replace assignements of the form:
/// `let old_offset = buf.seek(SeekFrom::Start(0))?;`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seek doesn't return the old position unless you do SeekFrom::Current(0)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See also the documentation of seek:

If the seek operation completed successfully, this method returns the new position from the start of the stream.

///
/// # Errors
///
Expand Down