1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*!
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();
}
```
!*/
pub use *;
/// Trait for consuming a struct or enum without dropping it while dropping all of its contents normally.