@@ -409,7 +409,9 @@ pub fn read_dir<F: FnMut(&Path)>(dir: impl AsRef<Path>, mut callback: F) {
409409
410410/// Check that `actual` is equal to `expected`. Panic otherwise.
411411#[ 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 ( ) ;
413415 if actual != expected {
414416 eprintln ! ( "=== ACTUAL TEXT ===" ) ;
415417 eprintln ! ( "{}" , actual) ;
@@ -421,7 +423,9 @@ pub fn assert_equals(actual: &str, expected: &str) {
421423
422424/// Check that `haystack` contains `needle`. Panic otherwise.
423425#[ 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 ( ) ;
425429 if !haystack. contains ( needle) {
426430 eprintln ! ( "=== HAYSTACK ===" ) ;
427431 eprintln ! ( "{}" , haystack) ;
@@ -433,7 +437,9 @@ pub fn assert_contains(haystack: &str, needle: &str) {
433437
434438/// Check that `haystack` does not contain `needle`. Panic otherwise.
435439#[ 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 ( ) ;
437443 if haystack. contains ( needle) {
438444 eprintln ! ( "=== HAYSTACK ===" ) ;
439445 eprintln ! ( "{}" , haystack) ;
0 commit comments