tagid-derive

Crates.iotagid-derive
lib.rstagid-derive
version0.2.0
created_at2025-02-12 04:19:26.97129+00
updated_at2025-02-12 04:19:26.97129+00
descriptionDefines a derive macro for the tagid newtype labeled tagging for different types of ids.
homepagehttps://github.com/dmrolfs/tagid-rs
repositoryhttps://github.com/dmrolfs/tagid-rs
max_upload_size
id1552548
size6,012
Damon Rolfs (dmrolfs)

documentation

https://docs.rs/tagid

README

tagid-derive - Procedural macro for deriving Label in the tagid crate

The tagid-derive crate provides a procedural macro to derive the Label trait from the tagid crate. This simplifies the implementation of label-based type identification.

Installation

Add the following to your Cargo.toml:

[dependencies]
tagid = "0.2"
tagid-derive = "0.2"

Usage

Deriving Label

The Label trait provides a compile-time string label for a type. To derive it, simply annotate your struct or enum with #[derive(Label)]:

use tagid::Label;

#[derive(Label)]
struct Order;

assert_eq!(Order::label(), "Order");

Now, Order::label() will return a unique string label for the type:

This is useful for logging, serialization, or any scenario where type-based labeling is needed.

License

This project is licensed under the MIT License. See LICENSE for details.

Commit count: 26

cargo fmt