field_names_derive

Crates.iofield_names_derive
lib.rsfield_names_derive
version0.1.0
created_at2026-01-15 18:23:18.422202+00
updated_at2026-01-15 18:23:18.422202+00
descriptionA simple procedural macro for Rust that generates field name constants for structs. Perfect for when you need compile-time field names for serialization, validation, database mapping, or configuration.
homepage
repositoryhttps://github.com/heart4it/field_names_derive
max_upload_size
id2046266
size21,467
(heart4it)

documentation

README

Introduction

A simple procedural macro for Rust that generates field name constants for structs. Perfect for when you need compile-time field names for serialization, validation, database mapping, or configuration.

Features

  • Simple - No complex configuration, just #[derive(FieldNames)]
  • IDE-friendly - Auto-generates helper modules for better IDE recognition
  • Preserves naming - Constants match field names exactly (no case conversion)
  • Compile-time constants - All field names available at compile time
  • Helper methods - Includes field_names() and has_field() methods

Installation

Add to your Cargo.toml:

[dependencies]
field_names_derive = "0.1"
use field_names_derive::FieldNames;

#[derive(FieldNames)]
struct User {
    id: u64,
    name: String,
}

// User::id; // "id"

Run tests: cargo test -- --nocapture

Run example: cargo run --bin simple_fields

Made with ❤️ for the Rust community

Commit count: 0

cargo fmt