Crates.io | cinner |
lib.rs | cinner |
version | 0.1.2 |
source | src |
created_at | 2022-11-29 14:12:46.580904 |
updated_at | 2022-12-14 18:28:51.629396 |
description | C++ style std input and std output with cin and cout |
homepage | |
repository | https://github.com/CroxxN/cinner |
max_upload_size | |
id | 725395 |
size | 5,420 |
cin
and cout
Because I'm bored of writing std::io::stdin().read_line(&mut holder).trim().parse::<T>()
and println!("{}", <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++ programmer I like C++ style
Operator overloading
with traits
(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
in generic functions
Variadics
(they're so cool)
Publishing crates to crates.io
cinner = "<version-no>"
to your Cargo.toml
fileuse cinner::{cin, cout};
fn main(){
let mut i = 0;
let _ = cin >> &mut i;
let _ = 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;
let _ = cin >> &mut i >> &mut j;
let _ = cout << i << "\n";
}
DCDA
© 2022 Sarad (Chronos Ltd.)