Skip to main content

BufferedInput

Struct BufferedInput 

Source
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: bool

Implementations§

Source§

impl<R: Read> BufferedInput<R>

Source

pub unsafe fn new(reader: R) -> Self

§Safety

Every scan must satisfy FastInput’s token requirements, including UTF-8.

Source

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>

Source§

fn skip_whitespace(&mut self)

Skips separators without consuming the next token.
Source§

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.
Source§

fn read_u8(&mut self) -> Option<u8>

Source§

fn read_u16(&mut self) -> Option<u16>

Source§

fn read_u32(&mut self) -> Option<u32>

Source§

fn read_u64(&mut self) -> Option<u64>

Source§

fn read_u128(&mut self) -> Option<u128>

Source§

fn read_usize(&mut self) -> Option<usize>

Source§

fn read_i8(&mut self) -> Option<i8>

Source§

fn read_i16(&mut self) -> Option<i16>

Source§

fn read_i32(&mut self) -> Option<i32>

Source§

fn read_i64(&mut self) -> Option<i64>

Source§

fn read_i128(&mut self) -> Option<i128>

Source§

fn read_isize(&mut self) -> Option<isize>

Source§

fn scan<T: Scan>(&mut self) -> T::Output

Panics if reading fails.
Source§

fn mscan<T: MarkedScan>(&mut self, marker: T) -> T::Output

Panics if reading fails.
Source§

fn scan_vec<T: Scan>(&mut self, size: usize) -> Vec<T::Output>

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToArrayVecScalar for T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.