Skip to content

Instantly share code, notes, and snippets.

@andraantariksa
Created March 3, 2019 04:27
Show Gist options
  • Save andraantariksa/e64fe5b789288122d1159d57a15398fc to your computer and use it in GitHub Desktop.
Save andraantariksa/e64fe5b789288122d1159d57a15398fc to your computer and use it in GitHub Desktop.
Rust simple input macro
macro_rules! input_vec {
() => {
input!()
.split_whitespace()
.map(|x| x.parse().unwrap())
.collect()
};
($delimiter:expr) => {
input!()
.split($delimiter)
.map(|x| x.parse().unwrap())
.collect()
};
}
macro_rules! read_line {
() => {{
let mut return_ = format!("");
std::io::stdin().read_line(&mut return_).unwrap();
return_.pop();
return_
}};
}
fn main() {
let v: Vec<i32> = input_vec!();
let input: String = input!()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment