galvanic-assert icon indicating copy to clipboard operation
galvanic-assert copied to clipboard

Add ability to check that some element matches a matcher

Open talzion12 opened this issue 5 years ago • 1 comments

I'd like to be able to write something like this:

struct Person {
  name: &'static str,
  age: u32,
}

let people = vec![
  Person {name: "Hi", age: 32 },
  Person {name: "Bye", age: 33 },
];

assert_that!(&people, contains_in_any_order(&[
  has_structure!(Person { name: eq("Hi") }),
  has_structure!(Person { name: eq("Bye") }),
]));

This probably doesn't compile, but I think it explains the issue well.

Great library btw =)

talzion12 avatar Jul 28 '20 14:07 talzion12

(sry I know that this is an old issue) Thanks! I'm not exactly what the problem is but the purpose for has_structure! is exactly the above scenario. Maybe I missed something though.

mindsbackyard avatar Jun 25 '23 09:06 mindsbackyard