Skip to main content

Crate fields_glob

Crate fields_glob 

Source
Expand description

Derived glob macro with the same name as the structure

§Examples

use fields_glob::fields_glob;

#[derive(fields_glob, Debug, Default)]
struct Foo {
    x: i32,
    y: i32,
    z: i32,
}

let y = 2;
let foo = Foo! { x: 1, z: 3, * };
assert_eq!(foo.x, 1);
assert_eq!(foo.y, 2);
assert_eq!(foo.z, 3);

let foo = Foo { x: 1, y: 2, z: 3 };
let Foo! { x: n, * } = foo; // pattern destructure
assert_eq!(n, 1);
assert_eq!(y, 2);
assert_eq!(z, 3);

Macros§

fields_glob_impl

Derive Macros§

fields_glob
Derived glob macro with the same name as the structure