readput

Crates.ioreadput
lib.rsreadput
version0.1.3
sourcesrc
created_at2023-10-30 12:04:51.32722
updated_at2024-11-09 19:08:11.339881
descriptionFast and easy stdin input parsing for competitive programming in rust.
homepage
repositoryhttps://github.com/thomasw04/readput
max_upload_size
id1018405
size12,454
Thomas Wachter (thomasw04)

documentation

README

readput

crates.io

Fast and easy stdin input parsing for competitive programming in rust.

Usage

Note: The inputs can be on the same line, or not, it doesn't make a difference. They are separated by spaces or line breaks. Excess inputs are getting cached for the next read() call.

Create a Scanner

Create a new Scanner. (Only ASCII support for now)

use readput::AsciiScanner;
use readput::Scanner;

let mut cin = AsciiScanner::new();

Read a single value

Note: They have to impl. FromStr and Debug.

let v = read!(cin, i128);

Read a tuple

let (a, b, c) = read!(cin, (String, i128, u32));
let (d, e) = read!(cin, (i32, i32));

Read a vector of tuples

Read a vector of tuples. 3 is the number of tuples in the vector to read.

let vec = read_vec!(cin, 3, (u32, String));

Read a vector of single values

Read a vector of single values. 3 is the number of elements to read. Note: They also have to impl. FromStr and Debug.

let vec: Vec<u32> = read_vec!(cin, 3, u32);

Iterate over input

Iterate over input. This will iterate forever. (Blocks until new input is entered).

for (a, b) in iter!(cin, (String, u32)) {
    println!("{} {}", a, b);
}
Commit count: 21

cargo fmt