fork download
  1. use std::{io::{Read, BufWriter, Write}, str::{FromStr, SplitWhitespace},cmp::*,num::*,i32::*,i64::*};
  2.  
  3. fn main() {
  4. let mut ip = "".to_owned();
  5. std::io::stdin().read_to_string(&mut ip);
  6. let mut it = ip.split_whitespace();
  7. macro_rules! inp {($($x:tt)*) => {($(it.next().unwrap().parse::<$x>().ok().unwrap()),*)};}
  8. let mut pw = BufWriter::new(std::io::stdout());
  9. macro_rules! out {($x:tt) => {write!(pw,$x)};}
  10.  
  11. // Example integer input
  12.  
  13. let x = inp!(i32);
  14.  
  15. // Example multiple input types
  16.  
  17. let (n,m) = inp!(i32 i32);
  18.  
  19. // Example output, same as regular rust formatting
  20.  
  21. out!("hello! this is x: {}",x);
  22.  
  23. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
1 1 1
compilation info
error: no rules expected the token `,`
  --> prog.rs:21:32
   |
9  |     macro_rules! out {($x:tt) => {write!(pw,$x)};}
   |     ---------------- when calling this macro
...
21 |     out!("hello! this is x: {}",x);
   |                                ^ no rules expected this token in macro call

warning: unused imports: `FromStr`, `SplitWhitespace`, `Write`, `cmp::*`, `i32::*`, `i64::*`, `num::*`
 --> prog.rs:1:33
  |
1 | use std::{io::{Read, BufWriter, Write}, str::{FromStr, SplitWhitespace},cmp::*,num::*,i32::*,i64::*};
  |                                 ^^^^^         ^^^^^^^  ^^^^^^^^^^^^^^^  ^^^^^^ ^^^^^^ ^^^^^^ ^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

error: aborting due to previous error; 1 warning emitted

stdout
Standard output is empty