delegare_derive

Crates.iodelegare_derive
lib.rsdelegare_derive
version0.11.0
sourcesrc
created_at2024-06-29 06:44:05.297849
updated_at2024-07-03 02:13:00.204202
descriptiondelegate struct easy
homepage
repositoryhttps://github.com/Bruce0203/delegare
max_upload_size
id1287173
size8,571
(Bruce0203)

documentation

README

delegare

Pros

  • Faster than auto_delegate crate
  • Easier than deleagate crate

Cons

example of this crate

#[delegate]
pub trait Read {
    fn read(&self) -> &usize;
}

#[derive(Delegate)]
struct Wrapper<R>
where
    R: Read,
{
    #[to(Read)]
    inner: R,
}

struct Io {
    value: usize,
}

impl Read for Io {
    fn read(&self) -> &usize {
        &self.value
    }
}

fn main() {
    let wrapper = Wrapper {
        inner: Io { value: 1 },
    };
    wrapper.read();
}
Commit count: 28

cargo fmt