@@ -409,7 +409,9 @@ pub fn read_dir<F: FnMut(&Path)>(dir: impl AsRef<Path>, mut callback: F) {
409
409
410
410
/// Check that `actual` is equal to `expected`. Panic otherwise.
411
411
#[ track_caller]
412
- pub fn assert_equals ( actual : & str , expected : & str ) {
412
+ pub fn assert_equals < S1 : AsRef < str > , S2 : AsRef < str > > ( actual : S1 , expected : S2 ) {
413
+ let actual = actual. as_ref ( ) ;
414
+ let expected = expected. as_ref ( ) ;
413
415
if actual != expected {
414
416
eprintln ! ( "=== ACTUAL TEXT ===" ) ;
415
417
eprintln ! ( "{}" , actual) ;
@@ -421,7 +423,9 @@ pub fn assert_equals(actual: &str, expected: &str) {
421
423
422
424
/// Check that `haystack` contains `needle`. Panic otherwise.
423
425
#[ track_caller]
424
- pub fn assert_contains ( haystack : & str , needle : & str ) {
426
+ pub fn assert_contains < S1 : AsRef < str > , S2 : AsRef < str > > ( haystack : S1 , needle : S2 ) {
427
+ let haystack = haystack. as_ref ( ) ;
428
+ let needle = needle. as_ref ( ) ;
425
429
if !haystack. contains ( needle) {
426
430
eprintln ! ( "=== HAYSTACK ===" ) ;
427
431
eprintln ! ( "{}" , haystack) ;
@@ -433,7 +437,9 @@ pub fn assert_contains(haystack: &str, needle: &str) {
433
437
434
438
/// Check that `haystack` does not contain `needle`. Panic otherwise.
435
439
#[ track_caller]
436
- pub fn assert_not_contains ( haystack : & str , needle : & str ) {
440
+ pub fn assert_not_contains < S1 : AsRef < str > , S2 : AsRef < str > > ( haystack : S1 , needle : S2 ) {
441
+ let haystack = haystack. as_ref ( ) ;
442
+ let needle = needle. as_ref ( ) ;
437
443
if haystack. contains ( needle) {
438
444
eprintln ! ( "=== HAYSTACK ===" ) ;
439
445
eprintln ! ( "{}" , haystack) ;
0 commit comments