| Crates.io | fields-glob |
| lib.rs | fields-glob |
| version | 0.1.3 |
| created_at | 2025-06-09 15:00:46.61176+00 |
| updated_at | 2025-07-24 10:25:27.048938+00 |
| description | Derived glob macro with the same name as the structure |
| homepage | |
| repository | https://github.com/A4-Tacks/fields-glob-rs |
| max_upload_size | |
| id | 1706026 |
| size | 10,491 |
Derived glob macro with the same name as the structure
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);