diff --git a/library/std/src/io/buffered/bufreader.rs b/library/std/src/io/buffered/bufreader.rs index 0b12e5777c840..30296f8a6a710 100644 --- a/library/std/src/io/buffered/bufreader.rs +++ b/library/std/src/io/buffered/bufreader.rs @@ -94,7 +94,9 @@ impl BufReader { pub fn with_capacity(capacity: usize, inner: R) -> BufReader { BufReader { inner, buf: Buffer::with_capacity(capacity) } } +} +impl BufReader { /// Attempt to look ahead `n` bytes. /// /// `n` must be less than `capacity`. @@ -117,7 +119,10 @@ impl BufReader { /// assert_eq!(&s, "hello"); /// ``` #[unstable(feature = "bufreader_peek", issue = "128405")] - pub fn peek(&mut self, n: usize) -> io::Result<&[u8]> { + pub fn peek(&mut self, n: usize) -> io::Result<&[u8]> + where + R: ?Sized, + { assert!(n <= self.capacity()); while n > self.buf.buffer().len() { if self.buf.pos() > 0 {