@@ -224,6 +224,16 @@ pub struct ExpectFile {
224224 pub position : & ' static str ,
225225}
226226
227+ /// Shared trait for [`Expect`] and [`ExpectFile`].
228+ pub trait Expectation {
229+ /// Checks if this expect is equal to actual.
230+ fn assert_eq ( & self , actual : & str ) ;
231+ /// Checks if this expect is equal to format!("{:#?}", actual).
232+ fn assert_debug_eq ( & self , actual : & impl Debug ) ;
233+ /// Returns the content of this expect.
234+ fn data ( & self ) -> String ;
235+ }
236+
227237/// Position of original `expect!` in the source file.
228238#[ derive( Debug ) ]
229239pub struct Position {
@@ -352,6 +362,18 @@ impl Expect {
352362 }
353363}
354364
365+ impl Expectation for Expect {
366+ fn assert_eq ( & self , actual : & str ) {
367+ self . assert_eq ( actual) ;
368+ }
369+ fn assert_debug_eq ( & self , actual : & impl Debug ) {
370+ self . assert_debug_eq ( actual) ;
371+ }
372+ fn data ( & self ) -> String {
373+ self . data ( ) . into ( )
374+ }
375+ }
376+
355377fn locate_end ( arg_start_to_eof : & str ) -> Option < usize > {
356378 match arg_start_to_eof. chars ( ) . next ( ) ? {
357379 c if c. is_whitespace ( ) => panic ! ( "skip whitespace before calling `locate_end`" ) ,
@@ -462,6 +484,18 @@ impl ExpectFile {
462484 }
463485}
464486
487+ impl Expectation for ExpectFile {
488+ fn assert_eq ( & self , actual : & str ) {
489+ self . assert_eq ( actual) ;
490+ }
491+ fn assert_debug_eq ( & self , actual : & impl Debug ) {
492+ self . assert_debug_eq ( actual) ;
493+ }
494+ fn data ( & self ) -> String {
495+ self . data ( )
496+ }
497+ }
498+
465499#[ derive( Default ) ]
466500struct Runtime {
467501 help_printed : bool ,
0 commit comments