pub struct BufferedInput<R> {
reader: R,
buffer: Vec<u8>,
input: FastInput,
filled: usize,
eof: bool,
}Expand description
Buffered token reader with the same token requirements as FastInput.
Tokens may span reads and borrowed tokens remain valid until the next scan.
Fields§
§reader: R§buffer: Vec<u8>§input: FastInput§filled: usize§eof: boolImplementations§
Source§impl<R: Read> BufferedInput<R>
impl<R: Read> BufferedInput<R>
Sourcefn refill(&mut self) -> bool
fn refill(&mut self) -> bool
Examples found in repository?
crates/competitive/src/tools/fastio.rs (line 741)
738 fn skip_whitespace(&mut self) {
739 loop {
740 self.input.skip_whitespace();
741 if self.input.ptr < self.input.end || !self.refill() {
742 break;
743 }
744 }
745 }
746
747 #[inline]
748 fn next_token(&mut self) -> Option<&str> {
749 if self.input.ptr >= self.input.end && !self.refill() {
750 return None;
751 }
752 Some(unsafe { std::str::from_utf8_unchecked(self.input.bytes()) })
753 }Trait Implementations§
Source§impl<R: Read> ScanSource for BufferedInput<R>
impl<R: Read> ScanSource for BufferedInput<R>
Source§fn skip_whitespace(&mut self)
fn skip_whitespace(&mut self)
Skips separators without consuming the next token.
Source§fn next_token(&mut self) -> Option<&str>
fn next_token(&mut self) -> Option<&str>
Reads a token under the source’s input requirements.
Checked sources return
None at EOF; unchecked sources require available input.fn read_u8(&mut self) -> Option<u8>
fn read_u16(&mut self) -> Option<u16>
fn read_u32(&mut self) -> Option<u32>
fn read_u64(&mut self) -> Option<u64>
fn read_u128(&mut self) -> Option<u128>
fn read_usize(&mut self) -> Option<usize>
fn read_i8(&mut self) -> Option<i8>
fn read_i16(&mut self) -> Option<i16>
fn read_i32(&mut self) -> Option<i32>
fn read_i64(&mut self) -> Option<i64>
fn read_i128(&mut self) -> Option<i128>
fn read_isize(&mut self) -> Option<isize>
Source§fn mscan<T: MarkedScan>(&mut self, marker: T) -> T::Output
fn mscan<T: MarkedScan>(&mut self, marker: T) -> T::Output
Panics if reading fails.
fn scan_vec<T: Scan>(&mut self, size: usize) -> Vec<T::Output>
fn iter<T: Scan>(&mut self) -> ScannerIter<'_, Self, T> ⓘ
Auto Trait Implementations§
impl<R> !Send for BufferedInput<R>
impl<R> !Sync for BufferedInput<R>
impl<R> Freeze for BufferedInput<R>where
R: Freeze,
impl<R> RefUnwindSafe for BufferedInput<R>where
R: RefUnwindSafe,
impl<R> Unpin for BufferedInput<R>where
R: Unpin,
impl<R> UnsafeUnpin for BufferedInput<R>where
R: UnsafeUnpin,
impl<R> UnwindSafe for BufferedInput<R>where
R: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more