fields-glob

Crates.iofields-glob
lib.rsfields-glob
version0.1.3
created_at2025-06-09 15:00:46.61176+00
updated_at2025-07-24 10:25:27.048938+00
descriptionDerived glob macro with the same name as the structure
homepage
repositoryhttps://github.com/A4-Tacks/fields-glob-rs
max_upload_size
id1706026
size10,491
A4-Tacks (A4-Tacks)

documentation

README

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);
# use fields_glob::fields_glob;
#
# #[derive(fields_glob, Debug, Default)]
# struct Foo {
#     x: i32,
#     y: i32,
#     z: i32,
# }

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);
Commit count: 2

cargo fmt