Skip to main content

Crate nulid_derive

Crate nulid_derive 

Source
Expand description

Derive macros for types that wrap Nulid.

This crate provides derive macros to automatically implement common traits for newtype wrappers around Nulid.

§Examples

use nulid::Nulid;
use nulid_derive::Id;

#[derive(Id)]
pub struct UserId(Nulid);

// Now you can use TryFrom:
let id = UserId::try_from("01HZQWER4TYUIOP9876QWERTY5")?;
let id2 = UserId::try_from("01HZQWER4TYUIOP9876QWERTY5".to_string())?;

Derive Macros§

Id
Derives common traits for types that wrap Nulid.