#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

#112 in #count

Download history 6415/week @ 2024-07-23 5421/week @ 2024-07-30 4874/week @ 2024-08-06 7631/week @ 2024-08-13 8110/week @ 2024-08-20 7100/week @ 2024-08-27 8086/week @ 2024-09-03 8073/week @ 2024-09-10 7042/week @ 2024-09-17 8826/week @ 2024-09-24 8941/week @ 2024-10-01 9009/week @ 2024-10-08 8986/week @ 2024-10-15 9139/week @ 2024-10-22 8285/week @ 2024-10-29 7651/week @ 2024-11-05

35,139 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
~38K SLoC