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:
commit
2bc7d4d70a
2 changed files with 5 additions and 2 deletions
|
@ -1759,7 +1759,6 @@ pub trait Seek {
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// #![feature(seek_rewind)]
|
|
||||||
/// use std::io::{Read, Seek, Write};
|
/// use std::io::{Read, Seek, Write};
|
||||||
/// use std::fs::OpenOptions;
|
/// use std::fs::OpenOptions;
|
||||||
///
|
///
|
||||||
|
@ -1777,7 +1776,7 @@ pub trait Seek {
|
||||||
/// f.read_to_string(&mut buf).unwrap();
|
/// f.read_to_string(&mut buf).unwrap();
|
||||||
/// assert_eq!(&buf, hello);
|
/// assert_eq!(&buf, hello);
|
||||||
/// ```
|
/// ```
|
||||||
#[unstable(feature = "seek_rewind", issue = "85149")]
|
#[stable(feature = "seek_rewind", since = "1.55.0")]
|
||||||
fn rewind(&mut self) -> Result<()> {
|
fn rewind(&mut self) -> Result<()> {
|
||||||
self.seek(SeekFrom::Start(0))?;
|
self.seek(SeekFrom::Start(0))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -336,6 +336,10 @@ fn seek_position() -> io::Result<()> {
|
||||||
assert_eq!(c.stream_position()?, 8);
|
assert_eq!(c.stream_position()?, 8);
|
||||||
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue