use-identifier 0.0.1

Composable string-backed identifier primitives for RustUse
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use use_identifier::{Identifier, IdentifierKind, TypedIdentifier};

struct Account;

impl IdentifierKind for Account {
    const NAME: &'static str = "account";
}

#[test]
fn typed_identifier_uses_validated_storage() -> Result<(), use_identifier::IdentifierError> {
    let plain = Identifier::new("acct_42")?;
    let typed = TypedIdentifier::<Account>::new("acct_42")?;

    assert_eq!(plain.as_str(), typed.as_str());
    assert_eq!(typed.kind_name(), "account");

    Ok(())
}