Derive the field count for a struct. Implements a FieldCount
trait. Supports generic structs.
# 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
}
This crate was inspired by the following StackOverflow answer by Lukas Kalbertodt.