field_count

Crates.iofield_count
lib.rsfield_count
version0.1.1
sourcesrc
created_at2020-09-22 19:02:05.712839
updated_at2020-09-23 10:07:42.79093
descriptionDerive the field count of a struct
homepage
repositoryhttps://github.com/discosultan/field-count
max_upload_size
id291743
size3,610
Jaanus Varus (discosultan)

documentation

README

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.

Commit count: 8

cargo fmt