Crates.io | field_count |
lib.rs | field_count |
version | 0.1.1 |
source | src |
created_at | 2020-09-22 19:02:05.712839 |
updated_at | 2020-09-23 10:07:42.79093 |
description | Derive the field count of a struct |
homepage | |
repository | https://github.com/discosultan/field-count |
max_upload_size | |
id | 291743 |
size | 3,610 |
Derive the field count for a struct.
# 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.