comp_input

Crates.iocomp_input
lib.rscomp_input
version0.2.2
sourcesrc
created_at2018-08-04 20:27:24.487186
updated_at2020-10-26 12:38:54.532942
descriptionInput library for competitive programming
homepage
repositoryhttps://github.com/mad-s/comp_input
max_upload_size
id77526
size10,979
mad-s (mad-s)

documentation

README

comp_input

crates.io docs.rs

Input library for competitive programming.

Example: weighted graph as edge list

#[macro_use]
extern crate comp_input;

fn main() {
    input! {
        n, m: usize,
        edges: [(usize1, usize1, u64); m],
    }
}

The variables n, m and edges then exist as local variables in scope.

List of input fragments

Fragment Description
u8, u16, u32, u64, usize Unsigned integer (base 10)
i8, i16, i32, i64, isize Signed integer (base 10, optional +/- prefix)
usize1 Like usize, but subtract 1 from the result (useful for 1-based input formats)
char A single character
String A sequence of non-ASCII-whitespace characters
(T1, T2), (T1, T2, T3), ... Heterogeneous tuple of other input fragments, read in order
[<T>; <n: expr>] n items parsed against T, returned as Vec
[<T>; const <n>] n items parsed against T, in an array. n must be compile-time constant

TODO

  • Allow arbitrary parse functions
  • Branching
  • Loops (e.g. parse until -1)

License

MIT/Apache-2.0

Commit count: 5

cargo fmt