2 releases

0.1.1 Sep 23, 2020
0.1.0 Sep 22, 2020

#24 in #u16

Download history 4231/week @ 2024-01-25 4910/week @ 2024-02-01 4118/week @ 2024-02-08 5550/week @ 2024-02-15 5476/week @ 2024-02-22 4229/week @ 2024-02-29 4173/week @ 2024-03-07 4314/week @ 2024-03-14 3617/week @ 2024-03-21 4022/week @ 2024-03-28 3669/week @ 2024-04-04 4522/week @ 2024-04-11 4894/week @ 2024-04-18 5121/week @ 2024-04-25 4099/week @ 2024-05-02 3951/week @ 2024-05-09

18,906 downloads per month

Custom license

3KB

field_count

Derive the field count for a struct.

📦 Getting Started

# Cargo.toml

[dependencies]
field_count = "0.1"
// main.rs

use field_count::FieldCount;

#[derive(FieldCount)]
struct MyStruct {
    first_field: i32,
    second_field: String,
    third_field: u16,
}

fn main() {
    println!("{}", MyStruct::field_count()); // 3
}

🙏 Credits

This crate was inspired by the following StackOverflow answer by Lukas Kalbertodt.

Dependencies

~1.5MB
~34K SLoC