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