#drop #macro-derive #derive #macro #destruct

macro destruct-drop-derive

Actual derive macro for destruct-drop

3 unstable releases

0.2.0 Jun 7, 2023
0.1.1 Sep 28, 2021
0.1.0 Sep 28, 2021

#7 in #destruct

Download history 27/week @ 2024-02-14 37/week @ 2024-02-21 72/week @ 2024-02-28 75/week @ 2024-03-06 106/week @ 2024-03-13 74/week @ 2024-03-20 78/week @ 2024-03-27 99/week @ 2024-04-03 85/week @ 2024-04-10 107/week @ 2024-04-17 48/week @ 2024-04-24 95/week @ 2024-05-01 25/week @ 2024-05-08 42/week @ 2024-05-15 78/week @ 2024-05-22 45/week @ 2024-05-29

202 downloads per month
Used in 6 crates (via destruct-drop)

MIT license

7KB
77 lines

destruct-drop

CI crates.io Documentation dependency status MIT

Macro for dropping the fields of a struct or enum without dropping the container.

Usage

Add #[derive(DestructDrop)] to your struct or enum definition.

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 or http://opensource.org/licenses/MIT)

Dependencies

~320–780KB
~19K SLoC