@@ -44,8 +44,7 @@ fn unordered_elements_are_matches_slice() -> Result<()> {
44
44
45
45
#[ test]
46
46
fn unordered_elements_are_matches_hash_map ( ) -> Result < ( ) > {
47
- let value: HashMap < u32 , & ' static str > =
48
- HashMap :: from_iter ( [ ( 1 , "One" ) , ( 2 , "Two" ) , ( 3 , "Three" ) ] ) ;
47
+ let value: HashMap < u32 , & ' static str > = HashMap :: from ( [ ( 1 , "One" ) , ( 2 , "Two" ) , ( 3 , "Three" ) ] ) ;
49
48
verify_that ! (
50
49
value,
51
50
unordered_elements_are![ ( eq( 2 ) , eq( "Two" ) ) , ( eq( 1 ) , eq( "One" ) ) , ( eq( 3 ) , eq( "Three" ) ) ]
@@ -54,8 +53,7 @@ fn unordered_elements_are_matches_hash_map() -> Result<()> {
54
53
55
54
#[ test]
56
55
fn unordered_elements_are_matches_hash_map_with_trailing_comma ( ) -> Result < ( ) > {
57
- let value: HashMap < u32 , & ' static str > =
58
- HashMap :: from_iter ( [ ( 1 , "One" ) , ( 2 , "Two" ) , ( 3 , "Three" ) ] ) ;
56
+ let value: HashMap < u32 , & ' static str > = HashMap :: from ( [ ( 1 , "One" ) , ( 2 , "Two" ) , ( 3 , "Three" ) ] ) ;
59
57
verify_that ! (
60
58
value,
61
59
unordered_elements_are![ ( eq( 2 ) , eq( "Two" ) ) , ( eq( 1 ) , eq( "One" ) ) , ( eq( 3 ) , eq( "Three" ) ) , ]
@@ -64,8 +62,7 @@ fn unordered_elements_are_matches_hash_map_with_trailing_comma() -> Result<()> {
64
62
65
63
#[ test]
66
64
fn unordered_elements_are_does_not_match_hash_map_with_wrong_key ( ) -> Result < ( ) > {
67
- let value: HashMap < u32 , & ' static str > =
68
- HashMap :: from_iter ( [ ( 1 , "One" ) , ( 2 , "Two" ) , ( 4 , "Three" ) ] ) ;
65
+ let value: HashMap < u32 , & ' static str > = HashMap :: from ( [ ( 1 , "One" ) , ( 2 , "Two" ) , ( 4 , "Three" ) ] ) ;
69
66
verify_that ! (
70
67
value,
71
68
not( unordered_elements_are![ ( eq( 2 ) , eq( "Two" ) ) , ( eq( 1 ) , eq( "One" ) ) , ( eq( 3 ) , eq( "Three" ) ) ] )
@@ -74,8 +71,7 @@ fn unordered_elements_are_does_not_match_hash_map_with_wrong_key() -> Result<()>
74
71
75
72
#[ test]
76
73
fn unordered_elements_are_does_not_match_hash_map_with_wrong_value ( ) -> Result < ( ) > {
77
- let value: HashMap < u32 , & ' static str > =
78
- HashMap :: from_iter ( [ ( 1 , "One" ) , ( 2 , "Two" ) , ( 3 , "Four" ) ] ) ;
74
+ let value: HashMap < u32 , & ' static str > = HashMap :: from ( [ ( 1 , "One" ) , ( 2 , "Two" ) , ( 3 , "Four" ) ] ) ;
79
75
verify_that ! (
80
76
value,
81
77
not( unordered_elements_are![ ( eq( 2 ) , eq( "Two" ) ) , ( eq( 1 ) , eq( "One" ) ) , ( eq( 3 ) , eq( "Three" ) ) ] )
@@ -84,7 +80,7 @@ fn unordered_elements_are_does_not_match_hash_map_with_wrong_value() -> Result<(
84
80
85
81
#[ test]
86
82
fn unordered_elements_are_does_not_match_hash_map_missing_element ( ) -> Result < ( ) > {
87
- let value: HashMap < u32 , & ' static str > = HashMap :: from_iter ( [ ( 1 , "One" ) , ( 2 , "Two" ) ] ) ;
83
+ let value: HashMap < u32 , & ' static str > = HashMap :: from ( [ ( 1 , "One" ) , ( 2 , "Two" ) ] ) ;
88
84
verify_that ! (
89
85
value,
90
86
not( unordered_elements_are![ ( eq( 2 ) , eq( "Two" ) ) , ( eq( 1 ) , eq( "One" ) ) , ( eq( 3 ) , eq( "Three" ) ) ] )
@@ -93,15 +89,13 @@ fn unordered_elements_are_does_not_match_hash_map_missing_element() -> Result<()
93
89
94
90
#[ test]
95
91
fn unordered_elements_are_does_not_match_hash_map_with_extra_element ( ) -> Result < ( ) > {
96
- let value: HashMap < u32 , & ' static str > =
97
- HashMap :: from_iter ( [ ( 1 , "One" ) , ( 2 , "Two" ) , ( 3 , "Three" ) ] ) ;
92
+ let value: HashMap < u32 , & ' static str > = HashMap :: from ( [ ( 1 , "One" ) , ( 2 , "Two" ) , ( 3 , "Three" ) ] ) ;
98
93
verify_that ! ( value, not( unordered_elements_are![ ( eq( 2 ) , eq( "Two" ) ) , ( eq( 1 ) , eq( "One" ) ) ] ) )
99
94
}
100
95
101
96
#[ test]
102
97
fn unordered_elements_are_does_not_match_hash_map_with_mismatched_key_and_value ( ) -> Result < ( ) > {
103
- let value: HashMap < u32 , & ' static str > =
104
- HashMap :: from_iter ( [ ( 1 , "One" ) , ( 2 , "Three" ) , ( 3 , "Two" ) ] ) ;
98
+ let value: HashMap < u32 , & ' static str > = HashMap :: from ( [ ( 1 , "One" ) , ( 2 , "Three" ) , ( 3 , "Two" ) ] ) ;
105
99
verify_that ! (
106
100
value,
107
101
not( unordered_elements_are![ ( eq( 2 ) , eq( "Two" ) ) , ( eq( 1 ) , eq( "One" ) ) , ( eq( 3 ) , eq( "Three" ) ) ] )
@@ -120,6 +114,25 @@ fn unordered_elements_are_matches_size() -> Result<()> {
120
114
verify_that ! ( value, not( unordered_elements_are![ eq( 1 ) , eq( 2 ) , eq( 3 ) ] ) )
121
115
}
122
116
117
+ #[ test]
118
+ fn unordered_elements_are_admits_matchers_without_static_lifetime ( ) -> Result < ( ) > {
119
+ #[ derive( Debug , PartialEq ) ]
120
+ struct AStruct ( i32 ) ;
121
+ let expected_value = AStruct ( 123 ) ;
122
+ verify_that ! ( vec![ AStruct ( 123 ) ] , unordered_elements_are![ eq_deref_of( & expected_value) ] )
123
+ }
124
+
125
+ #[ test]
126
+ fn unordered_elements_are_with_map_admits_matchers_without_static_lifetime ( ) -> Result < ( ) > {
127
+ #[ derive( Debug , PartialEq ) ]
128
+ struct AStruct ( i32 ) ;
129
+ let expected_value = AStruct ( 123 ) ;
130
+ verify_that ! (
131
+ HashMap :: from( [ ( 1 , AStruct ( 123 ) ) ] ) ,
132
+ unordered_elements_are![ ( eq( 1 ) , eq_deref_of( & expected_value) ) ]
133
+ )
134
+ }
135
+
123
136
#[ test]
124
137
fn unordered_elements_are_description_mismatch ( ) -> Result < ( ) > {
125
138
let result = verify_that ! ( vec![ 1 , 4 , 3 ] , unordered_elements_are![ eq( 1 ) , eq( 2 ) , eq( 3 ) ] ) ;
@@ -219,15 +232,13 @@ fn contains_each_supports_trailing_comma() -> Result<()> {
219
232
220
233
#[ test]
221
234
fn contains_each_matches_hash_map ( ) -> Result < ( ) > {
222
- let value: HashMap < u32 , & ' static str > =
223
- HashMap :: from_iter ( [ ( 1 , "One" ) , ( 2 , "Two" ) , ( 3 , "Three" ) ] ) ;
235
+ let value: HashMap < u32 , & ' static str > = HashMap :: from ( [ ( 1 , "One" ) , ( 2 , "Two" ) , ( 3 , "Three" ) ] ) ;
224
236
verify_that ! ( value, contains_each![ ( eq( 2 ) , eq( "Two" ) ) , ( eq( 1 ) , eq( "One" ) ) ] )
225
237
}
226
238
227
239
#[ test]
228
240
fn contains_each_matches_hash_map_with_trailing_comma ( ) -> Result < ( ) > {
229
- let value: HashMap < u32 , & ' static str > =
230
- HashMap :: from_iter ( [ ( 1 , "One" ) , ( 2 , "Two" ) , ( 3 , "Three" ) ] ) ;
241
+ let value: HashMap < u32 , & ' static str > = HashMap :: from ( [ ( 1 , "One" ) , ( 2 , "Two" ) , ( 3 , "Three" ) ] ) ;
231
242
verify_that ! ( value, contains_each![ ( eq( 2 ) , eq( "Two" ) ) , ( eq( 1 ) , eq( "One" ) ) , ] )
232
243
}
233
244
@@ -317,7 +328,7 @@ fn is_contained_supports_trailing_comma() -> Result<()> {
317
328
318
329
#[ test]
319
330
fn is_contained_in_matches_hash_map ( ) -> Result < ( ) > {
320
- let value: HashMap < u32 , & ' static str > = HashMap :: from_iter ( [ ( 1 , "One" ) , ( 2 , "Two" ) ] ) ;
331
+ let value: HashMap < u32 , & ' static str > = HashMap :: from ( [ ( 1 , "One" ) , ( 2 , "Two" ) ] ) ;
321
332
verify_that ! (
322
333
value,
323
334
is_contained_in![ ( eq( 2 ) , eq( "Two" ) ) , ( eq( 1 ) , eq( "One" ) ) , ( eq( 3 ) , eq( "Three" ) ) ]
@@ -326,7 +337,7 @@ fn is_contained_in_matches_hash_map() -> Result<()> {
326
337
327
338
#[ test]
328
339
fn is_contained_in_matches_hash_map_with_trailing_comma ( ) -> Result < ( ) > {
329
- let value: HashMap < u32 , & ' static str > = HashMap :: from_iter ( [ ( 1 , "One" ) , ( 2 , "Two" ) ] ) ;
340
+ let value: HashMap < u32 , & ' static str > = HashMap :: from ( [ ( 1 , "One" ) , ( 2 , "Two" ) ] ) ;
330
341
verify_that ! (
331
342
value,
332
343
is_contained_in![ ( eq( 2 ) , eq( "Two" ) ) , ( eq( 1 ) , eq( "One" ) ) , ( eq( 3 ) , eq( "Three" ) ) , ]
0 commit comments