2 releases

0.1.1 Sep 23, 2020
0.1.0 Sep 22, 2020

#17 in #u16

Download history 7227/week @ 2024-07-20 5533/week @ 2024-07-27 4898/week @ 2024-08-03 6658/week @ 2024-08-10 8496/week @ 2024-08-17 7968/week @ 2024-08-24 7351/week @ 2024-08-31 8328/week @ 2024-09-07 7233/week @ 2024-09-14 8101/week @ 2024-09-21 9155/week @ 2024-09-28 9544/week @ 2024-10-05 8584/week @ 2024-10-12 8907/week @ 2024-10-19 8781/week @ 2024-10-26 8287/week @ 2024-11-02

36,319 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
~37K SLoC