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