Skip to main content

Scanner

Struct Scanner 

Source
pub struct Scanner<'a, I: Iterator<Item = &'a str> = SplitAsciiWhitespace<'a>> {
    iter: I,
}

Fields§

§iter: I

Implementations§

Source§

impl<'a> Scanner<'a>

Source

pub fn new(s: &'a str) -> Self

Examples found in repository?
crates/aizu_online_judge/src/grl/grl_4_b.rs (line 13)
11pub fn judge_grl_4_b(input: impl Read, _output: impl Read, result: impl Read) -> bool {
12    let (s_in, s_res) = (read_all_unchecked(input), read_all_unchecked(result));
13    let (mut scanner_in, mut scanner_res) = (Scanner::new(&s_in), Scanner::new(&s_res));
14    scan!(scanner_in, vs, es, edges: [(usize, usize); iter es]);
15    let mut ord = vec![!0usize; vs];
16    let mut is_ac = true;
17    for (i, u) in scanner_res.iter::<usize>().take(vs).enumerate() {
18        is_ac &= ord[u] == !0usize;
19        ord[u] = i;
20    }
21    for (u, v) in edges {
22        is_ac &= ord[u] < ord[v];
23    }
24    is_ac
25}
Source§

impl<'a, I: Iterator<Item = &'a str>> Scanner<'a, I>

Source

pub fn new_from_iter(iter: I) -> Self

Examples found in repository?
crates/competitive/src/tools/scanner.rs (line 539)
538    fn mscan<I: ScanSource>(self, iter: &mut I) -> Option<Self::Output> {
539        let mut iter = Scanner::new_from_iter(iter.next_token()?.split(self.pat));
540        Some(from_fn(|| <T as Scan>::scan(&mut iter)).collect())
541    }
542}
543impl<T> MarkedScan for Splitted<T, &str>
544where
545    T: Scan,
546{
547    type Output = Vec<<T as Scan>::Output>;
548    fn mscan<I: ScanSource>(self, iter: &mut I) -> Option<Self::Output> {
549        let mut iter = Scanner::new_from_iter(iter.next_token()?.split(self.pat));
550        Some(from_fn(|| <T as Scan>::scan(&mut iter)).collect())
551    }

Trait Implementations§

Source§

impl<'a, I: Clone + Iterator<Item = &'a str>> Clone for Scanner<'a, I>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a, I: Debug + Iterator<Item = &'a str>> Debug for Scanner<'a, I>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, I: Iterator<Item = &'a str>> ScanSource for Scanner<'a, I>

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 skip_whitespace(&mut self)

Skips separators without consuming the next token.
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<'a, I> Freeze for Scanner<'a, I>
where I: Freeze,

§

impl<'a, I> RefUnwindSafe for Scanner<'a, I>
where I: RefUnwindSafe,

§

impl<'a, I> Send for Scanner<'a, I>
where I: Send,

§

impl<'a, I> Sync for Scanner<'a, I>
where I: Sync,

§

impl<'a, I> Unpin for Scanner<'a, I>
where I: Unpin,

§

impl<'a, I> UnsafeUnpin for Scanner<'a, I>
where I: UnsafeUnpin,

§

impl<'a, I> UnwindSafe for Scanner<'a, I>
where I: 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.