Skip to main content

Crate tagged_types_derive

Crate tagged_types_derive 

Source
Expand description

tagged-types-derive provides derive macro for a Tag types

To enable impementions on TaggedType it expects implementation of traits for Tag type. This crates give possibility of implementation of the traits using derive syntax.

Example with all defined attributes:

use tagged_types::TaggedType;
type Host = TaggedType<String, HostTag>;
#[derive(tagged_types_derive::Tag)]
#[implement(Default, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[transparent(Debug, Display, FromStr)]
#[capability(inner_access, from_inner)]
enum HostTag {}

let host = Host::default();

Alternative, using permissive attribute:

use tagged_types::TaggedType;
type Host = TaggedType<String, HostTag>;
#[derive(tagged_types_derive::Tag)]
#[permissive]
enum HostTag {}

let host = Host::default();

Derive Macrosยง

Tag
Attributes