ulid!() { /* proc-macro */ }
Expand description
Generate a new type for a ULID
The ulid!
macro generates a new type that is backed by a Ulid
from the ulid
crate. The
new type implements common traits like Display
and From<&str>
and From<String>
. The inner
value can be accessed using the get
method.
ยงExample
use typed_fields::ulid;
ulid!(UserId);
fn main() -> Result<(), Box<dyn std::error::Error>> {
let id: UserId = "01ARZ3NDEKTSV4RRFFQ69G5FAV".try_into()?;
// Do something with the URL...
}