Github Provide io::Seek::rewind by ijackson · Pull Request #85146 · rust-lang/ru...
source link: https://github.com/rust-lang/rust/pull/85146
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
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.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK