2 releases

0.1.1 Sep 23, 2020
0.1.0 Sep 22, 2020

#22 in #u16

Download history 4527/week @ 2024-05-07 5385/week @ 2024-05-14 4990/week @ 2024-05-21 5842/week @ 2024-05-28 4652/week @ 2024-06-04 6525/week @ 2024-06-11 6519/week @ 2024-06-18 5826/week @ 2024-06-25 5301/week @ 2024-07-02 6052/week @ 2024-07-09 7075/week @ 2024-07-16 6415/week @ 2024-07-23 5416/week @ 2024-07-30 4874/week @ 2024-08-06 7638/week @ 2024-08-13 7048/week @ 2024-08-20

26,093 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
~35K SLoC