Provide io::Seek::rewind by ijackson · Pull Request #85146 · rust-lang/rust (original) (raw)
Using Seek::seek
is slightly clumsy because of the need to write (or import) std::io::SeekFrom
to get at SeekStart
. C already has rewind
(although with broken error handling); we should have it too.
I'm motivated to do this because I've just found myself copy-pasting my 5-line extension trait between projects.
That the example ends up using OpenOptions
makes this look like a niche use case, but it is very common to rewind temporary files. tempfile
isn't available for use in this example or it would have looked shorter and more natural.
If this gets a positive reception I will open a tracking issue and update the feature gate.