I'm wondering if there is a more flexible matching pattern/crate/approach for asserts in unit tests.
In particular I often have cases where I want to assert against just a few fields of a big/deep struct. And I'd like to do it in a readable way... so it's clear what the test is testing. For example say I have a vec of items represented by this debug string:
[
Item {
id: 1,
children: []
...
}
Item {
id: 2,
children: []
...
}
...
]
Each item might have lots of fields, but for this particular test I only care that each item has a proper id. Is there an easy to read way that I can express this for unit tests? I imagine some sort of "matches" syntax like this would be ideal:
assert_matches!(vec, [ Item { id: 1 }, Item { id: 2 } ]);
Does such a thing or some alternative exist?
Thanks,
Jesse