Crates.io | fast_delegate |
lib.rs | fast_delegate |
version | 0.13.0 |
source | src |
created_at | 2024-07-07 10:37:52.934388 |
updated_at | 2024-07-24 01:50:00.888596 |
description | delegate struct easy |
homepage | |
repository | https://github.com/Bruce0203/delegare |
max_upload_size | |
id | 1294699 |
size | 11,857 |
fast_delegate
Pros
auto_delegate
cratedeleagate
crateCons
#[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();
}