https://github.com/ewpratten/thinwrap
Deref struct macros for Rust
https://github.com/ewpratten/thinwrap
rust rust-library rust-macros
Last synced: over 1 year ago
JSON representation
Deref struct macros for Rust
- Host: GitHub
- URL: https://github.com/ewpratten/thinwrap
- Owner: ewpratten
- License: gpl-3.0
- Created: 2021-05-14T23:20:48.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-05-15T12:57:31.000Z (about 5 years ago)
- Last Synced: 2025-02-10T11:51:15.107Z (over 1 year ago)
- Topics: rust, rust-library, rust-macros
- Language: Rust
- Homepage: https://crates.io/crates/thinwrap
- Size: 16.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ThinWrap
[](https://crates.io/crates/thinwrap) 
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.
## Example
**With ThinWrap:**
```rust
pub struct Inner;
thin_wrap!(pub, Outer, Inner);
```
**Without ThinWrap:**
```rust
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
}
}
```