pub struct Scanner<'a, I: Iterator<Item = &'a str> = SplitAsciiWhitespace<'a>> {
iter: I,
}Fields§
§iter: IImplementations§
Source§impl<'a> Scanner<'a>
impl<'a> Scanner<'a>
Sourcepub fn new(s: &'a str) -> Self
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>
impl<'a, I: Iterator<Item = &'a str>> Scanner<'a, I>
Sourcepub fn new_from_iter(iter: I) -> Self
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: Iterator<Item = &'a str>> ScanSource for Scanner<'a, I>
impl<'a, I: Iterator<Item = &'a str>> ScanSource for Scanner<'a, I>
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.Source§fn skip_whitespace(&mut self)
fn skip_whitespace(&mut self)
Skips separators without consuming the next token.
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<'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> 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