{"id":17346136,"url":"https://github.com/rushiimachine/field-count","last_synced_at":"2025-06-28T05:35:22.470Z","repository":{"id":209371025,"uuid":"723874919","full_name":"rushiiMachine/field-count","owner":"rushiiMachine","description":"Derive the field count for a struct/enum variant.","archived":false,"fork":false,"pushed_at":"2023-11-27T00:15:08.000Z","size":15,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-19T22:11:32.234Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rushiiMachine.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-11-27T00:07:23.000Z","updated_at":"2023-11-30T04:33:06.000Z","dependencies_parsed_at":"2023-11-27T01:27:32.400Z","dependency_job_id":"3c9c18bf-b768-42ac-9935-abfa7284d4cb","html_url":"https://github.com/rushiiMachine/field-count","commit_stats":null,"previous_names":["rushiimachine/field-count"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rushiiMachine%2Ffield-count","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rushiiMachine%2Ffield-count/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rushiiMachine%2Ffield-count/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rushiiMachine%2Ffield-count/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rushiiMachine","download_url":"https://codeload.github.com/rushiiMachine/field-count/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245832607,"owners_count":20679701,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-15T16:44:39.580Z","updated_at":"2025-03-27T10:42:39.627Z","avatar_url":"https://github.com/rushiiMachine.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# field_count\n\nDerive the field count for a struct / enum variants, generating implementations for the `FieldCount`\nand `EnumFieldCount` traits, respectively.\n\nThis is fork and continuation of the original [field_count](https://github.com/discosultan/field-count) project that is\nunmaintained.\n\n## Getting Started\n\n```toml\n# Cargo.toml\n\n[dependencies]\nfield_count = { git = \"https://github.com/rushiiMachine/field-count\" }\n```\n\n```rust\nuse field_count::FieldCount;\n\n// Two impls are generated, one implementing the FieldCount trait,\n// and the other a freestanding impl that has a const version of `field_count`\n#[derive(FieldCount)]\nstruct MyStruct {\n    first_field: i32,\n    second_field: String,\n    third_field: u16,\n}\n\nfn main() {\n    assert_eq!(MyStruct::field_count(), 3);\n}\n```\n\n```rust\nuse field_count::EnumFieldCount;\n\n#[derive(EnumFieldCount)]\nenum MyGenericEnum\u003cT\u003e {\n    Basic,\n    Gen(T),\n}\n\nfn main() {\n    let b: MyGenericEnum = MyGenericEnum::Basic::\u003ci32\u003e;\n    let g = MyGenericEnum::Gen(vec![1, 2, 3]);\n\n    assert_eq!(b.field_count(), 0);\n    assert_eq!(g.field_count(), 1);\n}\n```\n\n## Credits\n\nThis crate was inspired by [the following StackOverflow answer](https://stackoverflow.com/a/54177920/1466456)\nby [Lukas Kalbertodt](https://github.com/LukasKalbertodt).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frushiimachine%2Ffield-count","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frushiimachine%2Ffield-count","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frushiimachine%2Ffield-count/lists"}