traitful 0.3.0

A collection of helper macros for trait patterns
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use traitful::seal;

// Make it so that only cats and cat-people can meow
#[seal(Cat, CatPerson)]
pub trait Meow {
    fn meow() {
        println!("meow");
    }
}

pub struct Cat;

impl Meow for Cat {}

pub struct CatPerson;

// Will fail to compile if this line is commented out
impl Meow for CatPerson {}