#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

#111 in #count

Download history 4558/week @ 2023-12-18 1879/week @ 2023-12-25 2906/week @ 2024-01-01 4209/week @ 2024-01-08 4436/week @ 2024-01-15 4705/week @ 2024-01-22 4540/week @ 2024-01-29 4156/week @ 2024-02-05 5272/week @ 2024-02-12 5288/week @ 2024-02-19 4948/week @ 2024-02-26 4220/week @ 2024-03-04 4413/week @ 2024-03-11 3659/week @ 2024-03-18 3969/week @ 2024-03-25 3890/week @ 2024-04-01

16,227 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
~34K SLoC