-
Because I'm bored of writing
std::io::stdin().read_line(&mut holder).trim().parse::<T>()
andprintln!("{}", <variable>)
all the time -
Because I didn't find any other library that does this
-
Because I didn't have anything to do
-
Because
I'm a C++ programmerI like C++ IO style
-
Operator overloading
withtraits
(I'm still not sure if I did it right) -
The importance of
.trim()
(I forgot to add it in the first version and it took >5hrs to find the bug) -
Using
trait bounds
ingeneric functions
-
Variadics
(they're so cool) -
Publishing crates to
crates.io
- Add
cinner = "<version-no>"
to yourCargo.toml
file
use cinner::{cin, cout};
fn main(){
let mut i = 0;
// Must assign, even if to a void variable. Rust linter shouts about unused result otherwise.
_ = cin >> &mut i;
_ = cout << i << "\n";
}
fn main(){
let mut holder = String::new();
let i = std::io::stdin().read_line(&mut holder).trim().parse::<i32>().unwrap();
println!("{}", i);
}
use cinner::{cin, cout};
fn main(){
let mut i = 0;
let mut j = 0_f32;
_ = cin >> &mut i >> &mut j;
_ = cout << i << "\n";
}
- Cinner now supports "endl" functionality