File: simple.rs

package info (click to toggle)
rust-derive-destructure2 0.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 152 kB
  • sloc: makefile: 4
file content (30 lines) | stat: -rw-r--r-- 569 bytes parent folder | download
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
#[macro_use]
extern crate derive_destructure2;

#[derive(destructure, remove_trait_impls)]
struct Foo {
    x: i64,
    y: f32,
}

impl Drop for Foo {
    fn drop(&mut self) {
        panic!("We don't want to drop this");
    }
}

#[test]
fn test_simple_destructure() {
    let foo = Foo { x: 7, y: 8.9 };
    let (x, y) = foo.destructure();
    assert_eq!(x, 7);
    assert_eq!(y, 8.9);
}

#[test]
fn test_simple_remove_trait_impls() {
    let foo = Foo { x: 7, y: 8.9 };
    let foo = foo.remove_trait_impls();
    assert_eq!(foo.x, 7);
    assert_eq!(foo.y, 8.9);
}