Skip to content

Instantly share code, notes, and snippets.

@kaz
Created May 14, 2020 15:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaz/d1698f1087aa6918f8b542fd3368db44 to your computer and use it in GitHub Desktop.
Save kaz/d1698f1087aa6918f8b542fd3368db44 to your computer and use it in GitHub Desktop.
macro_rules! read {
() => {{
let mut buf = String::new();
std::io::stdin().read_line(&mut buf).unwrap();
buf
}};
( Vec<$t:ty> ) => {
read!()
.trim()
.split_whitespace()
.map(|x| x.parse::<$t>().unwrap())
.collect::<Vec<_>>()
};
( $( $t:ty ),* ) => {{
let buf = read!();
let mut iter = buf.split_whitespace().collect::<Vec<_>>().into_iter();
( $( iter.next().unwrap().parse::<$t>().unwrap() ),* )
}};
}
fn main() {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment