File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33All notable changes to insta and cargo-insta are documented here.
44
5+ ## 1.35.1
6+
7+ - Fixed a bug with diffs showing bogus newlines.
8+
59## 1.35.0
610
711- Fixed a crash when a file named ` .config ` was in the root.
Original file line number Diff line number Diff line change @@ -436,7 +436,7 @@ impl Snapshot {
436436
437437 /// The snapshot contents as a &str
438438 pub fn contents_str ( & self ) -> & str {
439- & self . snapshot . 0
439+ self . snapshot . as_str ( )
440440 }
441441
442442 fn serialize_snapshot ( & self , md : & MetaData ) -> String {
@@ -510,6 +510,13 @@ impl SnapshotContents {
510510 SnapshotContents ( get_inline_snapshot_value ( value) )
511511 }
512512
513+ /// Returns the snapshot contents as string with surrounding whitespace removed.
514+ pub fn as_str ( & self ) -> & str {
515+ self . 0
516+ . trim_start_matches ( |x| x == '\r' || x == '\n' )
517+ . trim_end ( )
518+ }
519+
513520 pub fn to_inline ( & self , indentation : usize ) -> String {
514521 let contents = & self . 0 ;
515522 let mut out = String :: new ( ) ;
@@ -576,13 +583,7 @@ impl From<SnapshotContents> for String {
576583
577584impl PartialEq for SnapshotContents {
578585 fn eq ( & self , other : & Self ) -> bool {
579- self . 0
580- . trim_start_matches ( |x| x == '\r' || x == '\n' )
581- . trim_end ( )
582- == other
583- . 0
584- . trim_start_matches ( |x| x == '\r' || x == '\n' )
585- . trim_end ( )
586+ self . as_str ( ) == other. as_str ( )
586587 }
587588}
588589
You can’t perform that action at this time.
0 commit comments