[−][src]Crate proconio_derive
Macros to easily derive Readable
and make stdout faster.
proconio_derive provides two procedural macros (attributes): derive_readable
and fastout
.
Examples for #[derive_readable]
use proconio::input; use proconio_derive::derive_readable; // Unit struct can derive readable. This generates a no-op for the reading. Not ignoring // the read value, but simply skip reading process. You cannot use it to discard the input. #[derive_readable] #[derive(PartialEq, Debug)] struct Weight; #[derive_readable] #[derive(PartialEq, Debug)] struct Cost(i32); #[derive_readable] #[derive(Debug)] struct Edge { from: usize, to: proconio::marker::Usize1, // The real Edge::to has type usize. weight: Weight, cost: Cost, } fn main() { input! { edge: Edge, } // if you enter "12 32 35" to the stdin, the values are as follows. assert_eq!(edge.from, 12); assert_eq!(edge.to, 31); assert_eq!(edge.weight, Weight); assert_eq!(edge.cost, Cost(35)); }
Examples for #[fastout]
use proconio_derive::fastout; #[fastout] fn main() { print!("{}{}, ", 'h', "ello"); // "hello" (no newline) println!("{}!", "world"); // "world!\n" println!("{}", 123456789); // "123456789\n" }
Attribute Macros
derive_readable | Derives |
fastout | Enables buffering for stdout. |