Skip to content

Commit 6280499

Browse files
committed
allow BufReader::peek to be called on unsized types
1 parent 600edc9 commit 6280499

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

+6-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ impl<R: Read> BufReader<R> {
9494
pub fn with_capacity(capacity: usize, inner: R) -> BufReader<R> {
9595
BufReader { inner, buf: Buffer::with_capacity(capacity) }
9696
}
97+
}
9798

99+
impl<R: Read + ?Sized> BufReader<R> {
98100
/// Attempt to look ahead `n` bytes.
99101
///
100102
/// `n` must be less than `capacity`.
@@ -117,7 +119,10 @@ impl<R: Read> BufReader<R> {
117119
/// assert_eq!(&s, "hello");
118120
/// ```
119121
#[unstable(feature = "bufreader_peek", issue = "128405")]
120-
pub fn peek(&mut self, n: usize) -> io::Result<&[u8]> {
122+
pub fn peek(&mut self, n: usize) -> io::Result<&[u8]>
123+
where
124+
R: ?Sized,
125+
{
121126
assert!(n <= self.capacity());
122127
while n > self.buf.buffer().len() {
123128
if self.buf.pos() > 0 {

0 commit comments

Comments
 (0)