#field #count #struct #derive

macro field_count_derive

Derive the field count for a struct

2 releases

0.1.1 Sep 23, 2020
0.1.0 Sep 22, 2020

#113 in #count

Download history 3969/week @ 2024-03-25 3890/week @ 2024-04-01 3901/week @ 2024-04-08 4522/week @ 2024-04-15 5571/week @ 2024-04-22 4550/week @ 2024-04-29 4238/week @ 2024-05-06 5160/week @ 2024-05-13 5295/week @ 2024-05-20 5698/week @ 2024-05-27 4445/week @ 2024-06-03 6128/week @ 2024-06-10 6776/week @ 2024-06-17 5847/week @ 2024-06-24 5391/week @ 2024-07-01 5944/week @ 2024-07-08

24,339 downloads per month
Used in field_count

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