8000 GitHub - discosultan/field-count: Derive the field count for a struct.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Nov 13, 2020. It is now read-only.

discosultan/field-count

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

field_count

Derive the field count for a struct. Implements a FieldCount trait. Supports generic structs.

📦 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.

About

Derive the field count for a struct.

Topics

Resources

License

Stars

Watchers

Forks

Languages

0