Skip to content

Commit fa5143f

Browse files
committed
Use the inner stream_len impl instead of using the Seek default
This is useful if stream_len is overridden by the Seek implementation of the inner member.
1 parent 3b4d6e0 commit fa5143f

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

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

+4
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,10 @@ impl<R: Seek> Seek for BufReader<R> {
489489
)
490490
})
491491
}
492+
493+
fn stream_len(&mut self) -> io::Result<u64> {
494+
self.inner.stream_len()
495+
}
492496
}
493497

494498
impl<T> SizeHint for BufReader<T> {

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

+4
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,10 @@ impl<W: Write + Seek> Seek for BufWriter<W> {
661661
self.flush_buf()?;
662662
self.get_mut().seek(pos)
663663
}
664+
665+
fn stream_len(&mut self) -> io::Result<u64> {
666+
self.inner.stream_len()
667+
}
664668
}
665669

666670
#[stable(feature = "rust1", since = "1.0.0")]

library/std/src/io/impls.rs

+10
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ impl<S: Seek + ?Sized> Seek for &mut S {
9393
fn stream_position(&mut self) -> io::Result<u64> {
9494
(**self).stream_position()
9595
}
96+
97+
#[inline]
98+
fn stream_len(&mut self) -> io::Result<u64> {
99+
(**self).stream_len()
100+
}
96101
}
97102
#[stable(feature = "rust1", since = "1.0.0")]
98103
impl<B: BufRead + ?Sized> BufRead for &mut B {
@@ -197,6 +202,11 @@ impl<S: Seek + ?Sized> Seek for Box<S> {
197202
fn stream_position(&mut self) -> io::Result<u64> {
198203
(**self).stream_position()
199204
}
205+
206+
#[inline]
207+
fn stream_len(&mut self) -> io::Result<u64> {
208+
(**self).stream_len()
209+
}
200210
}
201211
#[stable(feature = "rust1", since = "1.0.0")]
202212
impl<B: BufRead + ?Sized> BufRead for Box<B> {

0 commit comments

Comments
 (0)