Skip to content

Commit 025a850

Browse files
authored
Rollup merge of rust-lang#70904 - LukasKalbertodt:stabilize-seek-convenience, r=m-ou-se
Stabilize `Seek::stream_position` (feature `seek_convenience`) Tracking issue: rust-lang#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](rust-lang#59359 (comment)), `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.
2 parents e32f372 + 8a18fb0 commit 025a850

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

library/std/src/io/buffered/bufreader.rs

-1
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,6 @@ impl<R: Seek> Seek for BufReader<R> {
410410
/// # Example
411411
///
412412
/// ```no_run
413-
/// #![feature(seek_convenience)]
414413
/// use std::{
415414
/// io::{self, BufRead, BufReader, Seek},
416415
/// fs::File,

library/std/src/io/mod.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1671,7 +1671,7 @@ pub trait Seek {
16711671
/// # Example
16721672
///
16731673
/// ```no_run
1674-
/// #![feature(seek_convenience)]
1674+
/// #![feature(seek_stream_len)]
16751675
/// use std::{
16761676
/// io::{self, Seek},
16771677
/// fs::File,
@@ -1685,7 +1685,7 @@ pub trait Seek {
16851685
/// Ok(())
16861686
/// }
16871687
/// ```
1688-
#[unstable(feature = "seek_convenience", issue = "59359")]
1688+
#[unstable(feature = "seek_stream_len", issue = "59359")]
16891689
fn stream_len(&mut self) -> Result<u64> {
16901690
let old_pos = self.stream_position()?;
16911691
let len = self.seek(SeekFrom::End(0))?;
@@ -1706,7 +1706,6 @@ pub trait Seek {
17061706
/// # Example
17071707
///
17081708
/// ```no_run
1709-
/// #![feature(seek_convenience)]
17101709
/// use std::{
17111710
/// io::{self, BufRead, BufReader, Seek},
17121711
/// fs::File,
@@ -1723,7 +1722,7 @@ pub trait Seek {
17231722
/// Ok(())
17241723
/// }
17251724
/// ```
1726-
#[unstable(feature = "seek_convenience", issue = "59359")]
1725+
#[stable(feature = "seek_convenience", since = "1.51.0")]
17271726
fn stream_position(&mut self) -> Result<u64> {
17281727
self.seek(SeekFrom::Current(0))
17291728
}

0 commit comments

Comments
 (0)