use-id-prefix 0.0.1

Prefixed identifier primitives for RustUse
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use use_id_prefix::{PrefixedIdentifierKind, TypedPrefixedId};

struct User;

impl PrefixedIdentifierKind for User {
    const PREFIX: &'static str = "usr";
}

fn main() -> Result<(), use_id_prefix::IdPrefixError> {
    let typed = TypedPrefixedId::<User>::new("123")?;

    assert_eq!(typed.to_string(), "usr_123");

    Ok(())
}