Rollup merge of #70904 - LukasKalbertodt:stabilize-seek-convenience, r=m-ou-se
Stabilize `Seek::stream_position` (feature `seek_convenience`) Tracking issue: #59359 Unresolved questions from tracking issue: - "Override `stream_len` for `File`?" → we can do that in the future, this does not block stabilization. - "Rename to `len` and `position`?" → as noted in the tracking issue, both of these shorter names have problems (`len` is usually a cheap getter, `position` clashes with `Cursor`). I do think the current names are perfectly fine. - "Rename `stream_position` to `tell`?" → as mentioned in [the comment bringing this up](https://github.com/rust-lang/rust/issues/59359#issuecomment-559541545), `stream_position` is more descriptive. I don't think `tell` would be a good name. What remains to decide, is whether or not adding these methods is worth it.
This commit is contained in:
commit
025a850d21
@ -410,7 +410,6 @@ impl<R: Seek> Seek for BufReader<R> {
|
||||
/// # Example
|
||||
///
|
||||
/// ```no_run
|
||||
/// #![feature(seek_convenience)]
|
||||
/// use std::{
|
||||
/// io::{self, BufRead, BufReader, Seek},
|
||||
/// fs::File,
|
||||
|
@ -1671,7 +1671,7 @@ pub trait Seek {
|
||||
/// # Example
|
||||
///
|
||||
/// ```no_run
|
||||
/// #![feature(seek_convenience)]
|
||||
/// #![feature(seek_stream_len)]
|
||||
/// use std::{
|
||||
/// io::{self, Seek},
|
||||
/// fs::File,
|
||||
@ -1685,7 +1685,7 @@ pub trait Seek {
|
||||
/// Ok(())
|
||||
/// }
|
||||
/// ```
|
||||
#[unstable(feature = "seek_convenience", issue = "59359")]
|
||||
#[unstable(feature = "seek_stream_len", issue = "59359")]
|
||||
fn stream_len(&mut self) -> Result<u64> {
|
||||
let old_pos = self.stream_position()?;
|
||||
let len = self.seek(SeekFrom::End(0))?;
|
||||
@ -1706,7 +1706,6 @@ pub trait Seek {
|
||||
/// # Example
|
||||
///
|
||||
/// ```no_run
|
||||
/// #![feature(seek_convenience)]
|
||||
/// use std::{
|
||||
/// io::{self, BufRead, BufReader, Seek},
|
||||
/// fs::File,
|
||||
@ -1723,7 +1722,7 @@ pub trait Seek {
|
||||
/// Ok(())
|
||||
/// }
|
||||
/// ```
|
||||
#[unstable(feature = "seek_convenience", issue = "59359")]
|
||||
#[stable(feature = "seek_convenience", since = "1.51.0")]
|
||||
fn stream_position(&mut self) -> Result<u64> {
|
||||
self.seek(SeekFrom::Current(0))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user