10 releases

0.2.1 Apr 3, 2020
0.2.0 Apr 1, 2020
0.1.9 Mar 21, 2021
0.1.8 Nov 14, 2020
0.1.5 Jun 24, 2019

#88 in #readable

Download history 619/week @ 2024-03-15 978/week @ 2024-03-22 939/week @ 2024-03-29 760/week @ 2024-04-05 843/week @ 2024-04-12 878/week @ 2024-04-19 682/week @ 2024-04-26 674/week @ 2024-05-03 688/week @ 2024-05-10 757/week @ 2024-05-17 787/week @ 2024-05-24 725/week @ 2024-05-31 447/week @ 2024-06-07 674/week @ 2024-06-14 706/week @ 2024-06-21 315/week @ 2024-06-28

2,284 downloads per month
Used in 5 crates (2 directly)

MIT/Apache

22KB
346 lines

proconio-derive

crates.io docs.rs

This is procedural macros for proconio.


lib.rs:

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"
}

Dependencies

~1.5MB
~35K SLoC