Skip to content

Commit

Permalink
specialize Bytes on StdinLock<'_> by using the underlying `BufRea…
Browse files Browse the repository at this point in the history
…der`
  • Loading branch information
AldanTanneo committed Jan 17, 2024
1 parent bf2637f commit 1b9a013
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion library/std/src/io/stdio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ use crate::io::prelude::*;
use crate::cell::{Cell, RefCell};
use crate::fmt;
use crate::fs::File;
use crate::io::{self, BorrowedCursor, BufReader, IoSlice, IoSliceMut, LineWriter, Lines};
use crate::io::{
self, BorrowedCursor, BufReader, IoSlice, IoSliceMut, LineWriter, Lines, SpecReadByte,
};
use crate::sync::atomic::{AtomicBool, Ordering};
use crate::sync::{Arc, Mutex, MutexGuard, OnceLock, ReentrantMutex, ReentrantMutexGuard};
use crate::sys::stdio;
Expand Down Expand Up @@ -483,6 +485,13 @@ impl Read for StdinLock<'_> {
}
}

impl SpecReadByte for StdinLock<'_> {
#[inline]
fn spec_read_byte(&mut self) -> Option<io::Result<u8>> {
BufReader::spec_read_byte(&mut *self.inner)
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl BufRead for StdinLock<'_> {
fn fill_buf(&mut self) -> io::Result<&[u8]> {
Expand Down

0 comments on commit 1b9a013

Please sign in to comment.