https://github.com/openbytedev/destruct-drop
Macro for dropping the fields of a struct or enum without dropping the container.
https://github.com/openbytedev/destruct-drop
Last synced: 8 months ago
JSON representation
Macro for dropping the fields of a struct or enum without dropping the container.
- Host: GitHub
- URL: https://github.com/openbytedev/destruct-drop
- Owner: OpenByteDev
- License: mit
- Created: 2021-09-28T20:59:53.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-06-07T11:38:35.000Z (almost 3 years ago)
- Last Synced: 2025-02-28T07:17:52.277Z (about 1 year ago)
- Language: Rust
- Size: 11.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# destruct-drop
[](https://github.com/OpenByteDev/destruct-drop/actions/workflows/ci.yml)
[](https://crates.io/crates/destruct-drop)
[](https://docs.rs/destruct-drop)
[](https://deps.rs/repo/github/openbytedev/destruct-drop)
[](https://github.com/OpenByteDev/destruct-drop/blob/master/LICENSE)
Macro for dropping the fields of a struct or enum without dropping the container.
## Usage
Add `#[derive(DestructDrop)]` to your `struct` or `enum` definition.
```rust
use destruct_drop::DestructDrop;
#[derive(DestructDrop)]
struct Container {
inner: Inner
}
struct Inner;
impl Drop for Container {
fn drop(&mut self) {
println!("dropped Container");
}
}
impl Drop for Inner {
fn drop(&mut self) {
println!("dropped Inner");
}
}
fn main() {
// prints "dropped Inner" and then "dropped Container"
drop(Container { inner: Inner });
// prints only "dropped Inner"
Container { inner: Inner }.destruct_drop();
}
```
## License
Licensed under MIT license ([LICENSE](https://github.com/OpenByteDev/destruct-drop/blob/master/LICENSE) or http://opensource.org/licenses/MIT)