From 6ff13e40d205fb849b9c19eb8adb65f658965c59 Mon Sep 17 00:00:00 2001 From: Scott Robinson Date: Wed, 12 Jul 2023 23:05:02 +1000 Subject: [PATCH] Make the `data` from an `ExpectFile` accessible --- src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index c0c6dbf..877241b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -434,7 +434,7 @@ fn find_str_lit_len(str_lit_to_eof: &str) -> Option { impl ExpectFile { /// Checks if file contents is equal to `actual`. pub fn assert_eq(&self, actual: &str) { - let expected = self.read(); + let expected = self.data(); if actual == expected { return; } @@ -445,7 +445,8 @@ impl ExpectFile { let actual = format!("{:#?}\n", actual); self.assert_eq(&actual) } - fn read(&self) -> String { + /// Returns the content of this expect. + pub fn data(&self) -> String { fs::read_to_string(self.abs_path()).unwrap_or_default().replace("\r\n", "\n") } fn write(&self, contents: &str) {