Crates.io | delegare_derive |
lib.rs | delegare_derive |
version | 0.11.0 |
source | src |
created_at | 2024-06-29 06:44:05.297849 |
updated_at | 2024-07-03 02:13:00.204202 |
description | delegate struct easy |
homepage | |
repository | https://github.com/Bruce0203/delegare |
max_upload_size | |
id | 1287173 |
size | 8,571 |
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();
}