10 breaking releases

0.11.0 Jul 3, 2024
0.9.0 Jul 3, 2024

#12 in #delegates

27 downloads per month
Used in delegare

MIT license

9KB
170 lines

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();
}

Dependencies

~255–710KB
~17K SLoC