Crates.io | thinwrap |
lib.rs | thinwrap |
version | 1.0.0 |
source | src |
created_at | 2021-05-15 12:58:02.977625 |
updated_at | 2021-05-15 12:58:02.977625 |
description | Deref struct macros for Rust |
homepage | |
repository | |
max_upload_size | |
id | 397845 |
size | 39,334 |
ThinWrap is a very small Rust library that provides a macro (thin_wrap!
) to wrap any struct in an outer struct, and generate its Deref
and DerefMut
traits automatically.
With ThinWrap:
pub struct Inner;
thin_wrap!(pub, Outer, Inner);
Without ThinWrap:
pub struct Inner;
pub struct Outer(Inner);
impl Deref for Outer {
type Target = Inner;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl DerefMut for Outer {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}