From 901623006d8ff96d4f033651b80a31b5b458a59b Mon Sep 17 00:00:00 2001 From: Andrew Cowie Date: Mon, 1 Sep 2025 12:59:41 +1000 Subject: [PATCH] Fix compiler warnings --- src/language/quantity.rs | 2 +- src/language/types.rs | 14 +++++++------- src/parsing/mod.rs | 2 +- src/rendering/typst.rs | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/language/quantity.rs b/src/language/quantity.rs index 43b7361..89e2fb2 100644 --- a/src/language/quantity.rs +++ b/src/language/quantity.rs @@ -38,7 +38,7 @@ pub struct Decimal { } /// Parse a string as a Quantity if it matches the expected format -pub fn parse_quantity(input: &str) -> Option { +pub fn parse_quantity(input: &str) -> Option> { // Look for patterns that indicate a quantity: // - decimal number followed by space and unit symbol // - decimal number with uncertainty (±) diff --git a/src/language/types.rs b/src/language/types.rs index 31bbc7b..5e8c5a9 100644 --- a/src/language/types.rs +++ b/src/language/types.rs @@ -244,7 +244,7 @@ pub fn validate_template(input: &str) -> Option<&str> { } } -pub fn validate_identifier(input: &str) -> Option { +pub fn validate_identifier(input: &str) -> Option> { if input.len() == 0 { return None; } @@ -257,7 +257,7 @@ pub fn validate_identifier(input: &str) -> Option { } } -pub fn validate_forma(input: &str) -> Option { +pub fn validate_forma(input: &str) -> Option> { if input.len() == 0 { return None; } @@ -281,7 +281,7 @@ pub fn validate_forma(input: &str) -> Option { Some(Forma(input)) } -fn parse_tuple(input: &str) -> Option> { +fn parse_tuple(input: &str) -> Option>> { let mut formas: Vec = Vec::new(); for text in input.split(",") { @@ -294,7 +294,7 @@ fn parse_tuple(input: &str) -> Option> { } /// This one copes with (and discards) any internal whitespace encountered. -pub fn validate_genus(input: &str) -> Option { +pub fn validate_genus(input: &str) -> Option> { let first = input .chars() .next() @@ -349,7 +349,7 @@ pub fn validate_genus(input: &str) -> Option { } } -pub fn validate_response(input: &str) -> Option { +pub fn validate_response(input: &str) -> Option> { if input.len() == 0 { return None; } @@ -371,14 +371,14 @@ pub fn validate_response(input: &str) -> Option { Some(Response { value, condition }) } -fn _validate_decimal(_input: &str) -> Option { +fn _validate_decimal(_input: &str) -> Option> { // Test the regex macro availability within types.rs let _decimal_regex = regex!(r"^\s*-?[0-9]+\.[0-9]+\s*$"); // For now, just return None since we removed Decimal variant None } -pub fn validate_numeric(input: &str) -> Option { +pub fn validate_numeric(input: &str) -> Option> { if input.is_empty() { return None; } diff --git a/src/parsing/mod.rs b/src/parsing/mod.rs index 5f5bd1e..ac3beb3 100644 --- a/src/parsing/mod.rs +++ b/src/parsing/mod.rs @@ -12,7 +12,7 @@ mod scope; /// Read a file and return an owned String. We pass that ownership back to the /// main function so that the Technique object created by parse() below can /// have the same lifetime. -pub fn load(filename: &Path) -> Result { +pub fn load(filename: &Path) -> Result> { match std::fs::read_to_string(filename) { Ok(content) => Ok(content), Err(error) => { diff --git a/src/rendering/typst.rs b/src/rendering/typst.rs index 7de5354..31dff06 100644 --- a/src/rendering/typst.rs +++ b/src/rendering/typst.rs @@ -42,7 +42,7 @@ impl Render for Typst { } } -fn escape_typst(content: &str) -> Cow { +fn escape_typst(content: &str) -> Cow<'_, str> { if content.contains('"') { Cow::Owned(content.replace("\"", "\\\"")) } else {