@@ -1308,6 +1308,59 @@ macro_rules! expect_near {
1308
1308
/// equivalent to `ASSERT_THAT`, use [`verify_that!`] with the `?` operator.
1309
1309
#[ macro_export]
1310
1310
macro_rules! assert_that {
1311
+ // specialized to sequence:
1312
+ ( $actual: expr, [ $( $expected: expr) ,* ] $( , ) ?) => {
1313
+ match $crate:: verify_that!( $actual, [ $( $expected) ,* ] ) {
1314
+ Ok ( _) => { }
1315
+ Err ( e) => {
1316
+ // The extra newline before the assertion failure message makes the failure a
1317
+ // bit easier to read when there's some generic boilerplate from the panic.
1318
+ panic!( "\n {}" , e) ;
1319
+ }
1320
+ }
1321
+ } ;
1322
+
1323
+ // specialized to unordered sequence
1324
+ ( $actual: expr, { $( $expected: expr) ,* } $( , ) ?) => {
1325
+ match $crate:: verify_that!( $actual, { $( $expected) ,* } ) {
1326
+ Ok ( _) => { }
1327
+ Err ( e) => {
1328
+ // The extra newline before the assertion failure message makes the failure a
1329
+ // bit easier to read when there's some generic boilerplate from the panic.
1330
+ panic!( "\n {}" , e) ;
1331
+ }
1332
+ }
1333
+ } ;
1334
+
1335
+ // w/ format args, specialized to sequence:
1336
+ ( $actual: expr, [ $( $expected: expr) ,* ] , $( $format_args: expr) ,* $( , ) ?) => {
1337
+ match $crate:: verify_that!( $actual, [ $( $expected) ,* ] )
1338
+ . with_failure_message( || format!( $( $format_args) ,* ) )
1339
+ {
1340
+ Ok ( _) => { }
1341
+ Err ( e) => {
1342
+ // The extra newline before the assertion failure message makes the failure a
1343
+ // bit easier to read when there's some generic boilerplate from the panic.
1344
+ panic!( "\n {}" , e) ;
1345
+ }
1346
+ }
1347
+ } ;
1348
+
1349
+ // w/ format args, specialized to unordered sequence:
1350
+ ( $actual: expr, { $( $expected: expr) ,* } , $( $format_args: expr) ,* $( , ) ?) => {
1351
+ match $crate:: verify_that!( $actual, { $( $expected) ,* } )
1352
+ . with_failure_message( || format!( $( $format_args) ,* ) )
1353
+ {
1354
+ Ok ( _) => { }
1355
+ Err ( e) => {
1356
+ // The extra newline before the assertion failure message makes the failure a
1357
+ // bit easier to read when there's some generic boilerplate from the panic.
1358
+ panic!( "\n {}" , e) ;
1359
+ }
1360
+ }
1361
+ } ;
1362
+
1363
+ // general case:
1311
1364
( $actual: expr, $expected: expr $( , ) ?) => {
1312
1365
match $crate:: verify_that!( $actual, $expected) {
1313
1366
Ok ( _) => { }
@@ -1319,6 +1372,7 @@ macro_rules! assert_that {
1319
1372
}
1320
1373
} ;
1321
1374
1375
+ // w/ format args, general case:
1322
1376
( $actual: expr, $expected: expr, $( $format_args: expr) ,* $( , ) ?) => {
1323
1377
match $crate:: verify_that!( $actual, $expected)
1324
1378
. with_failure_message( || format!( $( $format_args) ,* ) )
0 commit comments