Crates.io | fast_delegate_derive |
lib.rs | fast_delegate_derive |
version | 0.11.0 |
source | src |
created_at | 2024-07-07 10:37:44.186839 |
updated_at | 2024-07-07 10:37:44.186839 |
description | delegate struct easy |
homepage | |
repository | https://github.com/Bruce0203/delegare |
max_upload_size | |
id | 1294698 |
size | 8,574 |
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();
}