From a5d0c48b35cd80787928d466d0287e6c85d432ac Mon Sep 17 00:00:00 2001 From: damc Date: Tue, 7 Feb 2023 19:17:57 +0100 Subject: [PATCH] improvement78 Remove `Option<>` wrapper from ReadUtf8 arg. There's no immediate usecase for distinguishing `Some`/`None`. --- sv-parser-error/src/lib.rs | 2 +- sv-parser-pp/src/preprocess.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sv-parser-error/src/lib.rs b/sv-parser-error/src/lib.rs index 3895cc3..56fd305 100644 --- a/sv-parser-error/src/lib.rs +++ b/sv-parser-error/src/lib.rs @@ -16,7 +16,7 @@ pub enum Error { }, #[error("File could not be read as UTF8: {0:?}")] - ReadUtf8(Option), + ReadUtf8(PathBuf), #[error("Include error")] Include { diff --git a/sv-parser-pp/src/preprocess.rs b/sv-parser-pp/src/preprocess.rs index 0bf18b6..9a01eff 100644 --- a/sv-parser-pp/src/preprocess.rs +++ b/sv-parser-pp/src/preprocess.rs @@ -151,7 +151,7 @@ fn preprocess_inner, U: AsRef, V: BuildHasher>( let mut s = String::new(); if let Err(_) = reader.read_to_string(&mut s) { - Err(Error::ReadUtf8(Some(PathBuf::from(path.as_ref())))) + Err(Error::ReadUtf8(PathBuf::from(path.as_ref()))) } else { preprocess_str( &s, @@ -1123,10 +1123,10 @@ mod tests { Error::ReadUtf8(path) => { assert_eq!( path, - Some(PathBuf::from(format!( + PathBuf::from(format!( "{}/testcases/err_ReadUtf8.sv", env::var("CARGO_MANIFEST_DIR").unwrap(), - ))) + )) ); } _ => {