10 个版本

0.2.1 2020年4月3日
0.2.0 2020年4月1日
0.1.9 2021年3月21日
0.1.8 2020年11月14日
0.1.5 2019年6月24日

#readable 中排名第 82

Download history 599/week @ 2024-01-05 779/week @ 2024-01-12 573/week @ 2024-01-19 417/week @ 2024-01-26 201/week @ 2024-02-02 1025/week @ 2024-02-09 865/week @ 2024-02-16 609/week @ 2024-02-23 825/week @ 2024-03-01 1043/week @ 2024-03-08 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 670/week @ 2024-04-19

每月下载量 3,275
用于 5crate(2 个直接使用)

MIT/Apache

22KB
346

proconio-derive

crates.io docs.rs

这是为proconio编写的进程宏。


lib.rs:

宏,可轻松推导出 Readable 并使stdout更快。

proconio_derive提供两个进程宏(属性):derive_readablefastout

#[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));
}

#[fastout] 的示例

use proconio_derive::fastout;

#[fastout]
fn main() {
    print!("{}{}, ", 'h', "ello"); // "hello"       (no newline)
    println!("{}!", "world");      // "world!\n"
    println!("{}", 123456789);     // "123456789\n"
}

依赖项

~1.5MB
~33K SLoC