File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,8 @@ macro_rules! file {
22
22
} } ;
23
23
[ _ : $type: ident] => { {
24
24
let stem = :: std:: path:: Path :: new( :: std:: file!( ) ) . file_stem( ) . unwrap( ) ;
25
- let rel_path = :: std:: format!( "snapshots/{}-{}.txt" , stem. to_str( ) . unwrap( ) , line!( ) ) ;
25
+ let ext = $type. ext( ) ;
26
+ let rel_path = :: std:: format!( "snapshots/{}-{}.{ext}" , stem. to_str( ) . unwrap( ) , line!( ) ) ;
26
27
let mut path = $crate:: current_dir!( ) ;
27
28
path. push( rel_path) ;
28
29
$crate:: Data :: read_from( & path, Some ( $crate:: DataFormat :: $type) )
@@ -356,6 +357,18 @@ pub enum DataFormat {
356
357
Json ,
357
358
}
358
359
360
+ impl DataFormat {
361
+ pub fn ext ( self ) -> & ' static str {
362
+ match self {
363
+ Self :: Error => "txt" ,
364
+ Self :: Binary => "bin" ,
365
+ Self :: Text => "txt" ,
366
+ #[ cfg( feature = "json" ) ]
367
+ Self :: Json => "json" ,
368
+ }
369
+ }
370
+ }
371
+
359
372
#[ derive( Clone , Debug , PartialEq , Eq ) ]
360
373
pub struct DataSource {
361
374
inner : DataSourceInner ,
You can’t perform that action at this time.
0 commit comments