typed-fields 0.3.0

A collection of macros that generate newtypes
Documentation

This crate contains a set of macros that can be used to generate strongly-typed fields for structs. The macros implement the newtype pattern, which allows the compiler to enforce type safety while still making it easy to convert the fields to and from their underlying representation.

Example

use typed_fields::number;

// Define a new type that is backed by an `i64`
number!(UserId);

// Create a new `UserId` from an `i64`
let id = UserId::new(42);

// Common traits like `Display` are automatically implemented for the type
println!("User ID: {}", id);