Skip to content

ewpratten/thinwrap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ThinWrap

Crates.io Build

ThinWrap is a very small Rust library that provides a macro (thin_wrap!) to wrap any struct in an outer struct, and generate its Deref and DerefMut traits automatically.

Example

With ThinWrap:

pub struct Inner;

thin_wrap!(pub, Outer, Inner);

Without ThinWrap:

pub struct Inner;

pub struct Outer(Inner);

impl Deref for Outer {
    type Target = Inner;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl DerefMut for Outer {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Languages