#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 1/week @ 2024-01-01 56/week @ 2024-01-08 22/week @ 2024-01-22 338/week @ 2024-01-29 10/week @ 2024-02-05 22/week @ 2024-02-12 29/week @ 2024-02-19 52/week @ 2024-02-26 82/week @ 2024-03-04 123/week @ 2024-03-11 66/week @ 2024-03-18 52/week @ 2024-03-25 124/week @ 2024-04-01 60/week @ 2024-04-08 145/week @ 2024-04-15

386 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–770KB
~18K SLoC