Skip to content

A bunch of derive traits for wrapper types

License

Apache-2.0, Apache-2.0 licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
Apache-2.0
LICENSE-MIT
Notifications You must be signed in to change notification settings

elichai/derive-wrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Derive-Wrapper

Build Status Latest version License

A custom derive macro helper that let's you easily derive traits for wrapper types.

Examples:

#[derive(Debug, Default, Index, AsRef, LowerHexIter)]
struct Array32([u8; 32]);

#[derive(Debug, Default, LowerHex)]
struct Flag(i32);

#[derive(Debug, Index, LowerHexIter)]
struct Hi {
    #[wrap]
    a: [u8; 32],
    b: Flag,
}

#[derive(Debug, Display, From, Error)]
#[display_from(Debug)]
struct Printer<T: std::fmt::Debug>(T);

#[derive(Default, LowerHex, Display)]
#[display_from(LowerHex)]
#[wrap = "two"]
struct Big {
    one: Array32,
    two: Hi,
}

#[derive(From)]
enum MyEnum<T> {
    #[derive_from]
    First(u8),
    #[derive_from]
    Second(Array32),
    Third,
    #[derive_from]
    Fourth {
        other: Vec<u8>,
    },
    #[derive_from]
    Fifth(PhantomData<T>),
    #[derive_from(f32, f64)]
    Floats,
    #[derive_from(std::io::Error, std::fmt::Error)]
    Errors,

}

About

A bunch of derive traits for wrapper types

Resources

License

Apache-2.0, Apache-2.0 licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
Apache-2.0
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages