Rollup merge of #86794 - inquisitivecrystal:seek-rewind, r=m-ou-se

Stabilize `Seek::rewind()`

This stabilizes `Seek::rewind`. It seemed to fit into one of the existing tests, so I extended that test rather than adding a new one.

Closes #85149.
This commit is contained in:
Yuki Okushi 2021-07-06 02:33:15 +09:00 committed by GitHub
commit 2bc7d4d70a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -1759,7 +1759,6 @@ pub trait Seek {
/// # Example
///
/// ```no_run
/// #![feature(seek_rewind)]
/// use std::io::{Read, Seek, Write};
/// use std::fs::OpenOptions;
///
@ -1777,7 +1776,7 @@ pub trait Seek {
/// f.read_to_string(&mut buf).unwrap();
/// assert_eq!(&buf, hello);
/// ```
#[unstable(feature = "seek_rewind", issue = "85149")]
#[stable(feature = "seek_rewind", since = "1.55.0")]
fn rewind(&mut self) -> Result<()> {
self.seek(SeekFrom::Start(0))?;
Ok(())

View File

@ -336,6 +336,10 @@ fn seek_position() -> io::Result<()> {
assert_eq!(c.stream_position()?, 8);
assert_eq!(c.stream_position()?, 8);
c.rewind()?;
assert_eq!(c.stream_position()?, 0);
assert_eq!(c.stream_position()?, 0);
Ok(())
}