From 808c9db0078b0c423a9ea8c82798b0483bec7552 Mon Sep 17 00:00:00 2001 From: Tpt Date: Thu, 22 Dec 2022 21:47:14 +0100 Subject: [PATCH] String formatting: uses inline syntax --- lib/benches/store.rs | 7 +- lib/oxrdf/src/blank_node.rs | 2 +- lib/oxrdf/src/dataset.rs | 6 +- lib/oxrdf/src/literal.rs | 4 +- lib/oxrdf/src/parser.rs | 26 ++-- lib/oxrdf/src/triple.rs | 4 +- lib/sparesults/src/csv.rs | 10 +- lib/sparesults/src/json.rs | 37 ++--- lib/sparesults/src/solution.rs | 6 +- lib/sparesults/src/xml.rs | 30 ++-- lib/spargebra/src/algebra.rs | 190 +++++++++++------------ lib/spargebra/src/parser.rs | 2 +- lib/spargebra/src/query.rs | 16 +- lib/spargebra/src/term.rs | 28 ++-- lib/spargebra/src/update.rs | 28 ++-- lib/sparql-smith/src/lib.rs | 232 ++++++++++++++--------------- lib/src/io/error.rs | 4 +- lib/src/io/write.rs | 6 +- lib/src/sparql/error.rs | 2 +- lib/src/sparql/eval.rs | 3 +- lib/src/sparql/http/simple.rs | 4 +- lib/src/sparql/plan_builder.rs | 6 +- lib/src/sparql/service.rs | 3 +- lib/src/sparql/update.rs | 12 +- lib/src/storage/backend/rocksdb.rs | 6 +- lib/src/storage/mod.rs | 10 +- lib/src/storage/numeric_encoder.rs | 3 +- lib/src/storage/small_string.rs | 3 +- lib/src/xsd/date_time.rs | 18 +-- lib/src/xsd/duration.rs | 14 +- lib/src/xsd/parser.rs | 18 +-- oxrocksdb-sys/build.rs | 2 +- python/src/io.rs | 6 +- python/src/store.rs | 9 +- server/src/main.rs | 25 ++-- testsuite/src/manifest.rs | 12 +- testsuite/src/parser_evaluator.rs | 2 +- testsuite/src/sparql_evaluator.rs | 6 +- 38 files changed, 379 insertions(+), 423 deletions(-) diff --git a/lib/benches/store.rs b/lib/benches/store.rs index 492a9e6c..569821f8 100644 --- a/lib/benches/store.rs +++ b/lib/benches/store.rs @@ -102,7 +102,7 @@ fn store_query_and_update(c: &mut Criterion) { match kind { "query" => Operation::Query(Query::parse(operation, None).unwrap()), "update" => Operation::Update(Update::parse(operation, None).unwrap()), - _ => panic!("Unexpected operation kind {}", kind), + _ => panic!("Unexpected operation kind {kind}"), } }) .collect::>(); @@ -169,10 +169,7 @@ fn read_data(file: &str) -> impl BufRead { if !Path::new(file).exists() { let mut client = oxhttp::Client::new(); client.set_redirection_limit(5); - let url = format!( - "https://github.com/Tpt/bsbm-tools/releases/download/v0.2/{}", - file - ); + let url = format!("https://github.com/Tpt/bsbm-tools/releases/download/v0.2/{file}"); let request = Request::builder(Method::GET, url.parse().unwrap()).build(); let response = client.request(request).unwrap(); assert_eq!( diff --git a/lib/oxrdf/src/blank_node.rs b/lib/oxrdf/src/blank_node.rs index 76d161c3..938461e9 100644 --- a/lib/oxrdf/src/blank_node.rs +++ b/lib/oxrdf/src/blank_node.rs @@ -251,7 +251,7 @@ impl IdStr { #[inline] fn new(id: u128) -> Self { let mut str = [0; 32]; - write!(&mut str[..], "{:x}", id).unwrap(); + write!(&mut str[..], "{id:x}").unwrap(); Self(str) } diff --git a/lib/oxrdf/src/dataset.rs b/lib/oxrdf/src/dataset.rs index fb9ac9ef..527dad52 100644 --- a/lib/oxrdf/src/dataset.rs +++ b/lib/oxrdf/src/dataset.rs @@ -901,7 +901,7 @@ impl<'a, T: Into>> Extend for Dataset { impl fmt::Display for Dataset { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { for t in self { - writeln!(f, "{}", t)?; + writeln!(f, "{t}")?; } Ok(()) } @@ -1236,7 +1236,7 @@ impl<'a, 'b> IntoIterator for &'b GraphView<'a> { impl<'a> fmt::Display for GraphView<'a> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { for t in self { - writeln!(f, "{}", t)?; + writeln!(f, "{t}")?; } Ok(()) } @@ -1438,7 +1438,7 @@ impl<'a> IntoIterator for &'a GraphViewMut<'a> { impl<'a> fmt::Display for GraphViewMut<'a> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { for t in self { - writeln!(f, "{}", t)?; + writeln!(f, "{t}")?; } Ok(()) } diff --git a/lib/oxrdf/src/literal.rs b/lib/oxrdf/src/literal.rs index 4948b745..048d6323 100644 --- a/lib/oxrdf/src/literal.rs +++ b/lib/oxrdf/src/literal.rs @@ -440,11 +440,11 @@ impl fmt::Display for LiteralRef<'_> { LiteralRefContent::String(value) => print_quoted_str(value, f), LiteralRefContent::LanguageTaggedString { value, language } => { print_quoted_str(value, f)?; - write!(f, "@{}", language) + write!(f, "@{language}") } LiteralRefContent::TypedLiteral { value, datatype } => { print_quoted_str(value, f)?; - write!(f, "^^{}", datatype) + write!(f, "^^{datatype}") } } } diff --git a/lib/oxrdf/src/parser.rs b/lib/oxrdf/src/parser.rs index 7e3f8a32..283b48e1 100644 --- a/lib/oxrdf/src/parser.rs +++ b/lib/oxrdf/src/parser.rs @@ -410,23 +410,17 @@ impl fmt::Display for TermParseError { #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match &self.kind { - TermParseErrorKind::Iri { error, value } => write!( - f, - "Error while parsing the named node '{}': {}", - value, error - ), - TermParseErrorKind::BlankNode { error, value } => write!( - f, - "Error while parsing the blank node '{}': {}", - value, error - ), - TermParseErrorKind::LanguageTag { error, value } => write!( - f, - "Error while parsing the language tag '{}': {}", - value, error - ), + TermParseErrorKind::Iri { error, value } => { + write!(f, "Error while parsing the named node '{value}': {error}") + } + TermParseErrorKind::BlankNode { error, value } => { + write!(f, "Error while parsing the blank node '{value}': {error}") + } + TermParseErrorKind::LanguageTag { error, value } => { + write!(f, "Error while parsing the language tag '{value}': {error}") + } TermParseErrorKind::Variable { error, value } => { - write!(f, "Error while parsing the variable '{}': {}", value, error) + write!(f, "Error while parsing the variable '{value}': {error}") } TermParseErrorKind::Msg { msg } => f.write_str(msg), } diff --git a/lib/oxrdf/src/triple.rs b/lib/oxrdf/src/triple.rs index d91c287c..4006c8fa 100644 --- a/lib/oxrdf/src/triple.rs +++ b/lib/oxrdf/src/triple.rs @@ -308,7 +308,7 @@ impl fmt::Display for SubjectRef<'_> { Self::NamedNode(node) => node.fmt(f), Self::BlankNode(node) => node.fmt(f), #[cfg(feature = "rdf-star")] - Self::Triple(triple) => write!(f, "<<{}>>", triple), + Self::Triple(triple) => write!(f, "<<{triple}>>"), } } } @@ -588,7 +588,7 @@ impl fmt::Display for TermRef<'_> { Self::Literal(literal) => literal.fmt(f), #[cfg(feature = "rdf-star")] Self::Triple(triple) => { - write!(f, "<<{}>>", triple) + write!(f, "<<{triple}>>") } } } diff --git a/lib/sparesults/src/csv.rs b/lib/sparesults/src/csv.rs index 5f33f914..78df0511 100644 --- a/lib/sparesults/src/csv.rs +++ b/lib/sparesults/src/csv.rs @@ -210,14 +210,12 @@ impl TsvQueryResultsReader { for v in buffer.split('\t') { let v = v.trim(); let variable = Variable::from_str(v).map_err(|e| { - SyntaxError::msg(format!("Invalid variable declaration '{}': {}", v, e)) + SyntaxError::msg(format!("Invalid variable declaration '{v}': {e}")) })?; if variables.contains(&variable) { - return Err(SyntaxError::msg(format!( - "The variable {} is declared twice", - variable - )) - .into()); + return Err( + SyntaxError::msg(format!("The variable {variable} is declared twice")).into(), + ); } variables.push(variable); } diff --git a/lib/sparesults/src/json.rs b/lib/sparesults/src/json.rs index 9e9772c6..dad446c8 100644 --- a/lib/sparesults/src/json.rs +++ b/lib/sparesults/src/json.rs @@ -198,8 +198,7 @@ impl JsonQueryResultsReader { } _ => { return Err(SyntaxError::msg(format!( - "Expecting head or result key, found {}", - key + "Expecting head or result key, found {key}" )) .into()); } @@ -239,8 +238,7 @@ impl JsonSolutionsReader { JsonEvent::ObjectKey(key) => { let k = *self.mapping.get(key).ok_or_else(|| { SyntaxError::msg(format!( - "The variable {} has not been defined in the header", - key + "The variable {key} has not been defined in the header" )) })?; new_bindings[k] = Some(self.read_value(0)?) @@ -253,8 +251,7 @@ impl JsonSolutionsReader { fn read_value(&mut self, number_of_recursive_calls: usize) -> Result { if number_of_recursive_calls == MAX_NUMBER_OF_NESTED_TRIPLES { return Err(SyntaxError::msg(format!( - "Too many nested triples ({}). The parser fails here to avoid a stack overflow.", - MAX_NUMBER_OF_NESTED_TRIPLES + "Too many nested triples ({MAX_NUMBER_OF_NESTED_TRIPLES}). The parser fails here to avoid a stack overflow." )) .into()); } @@ -297,8 +294,7 @@ impl JsonSolutionsReader { "object" => object = Some(self.read_value(number_of_recursive_calls + 1)?), _ => { return Err(SyntaxError::msg(format!( - "Unexpected key in term serialization: '{}'", - key + "Unexpected key in term serialization: '{key}'" )) .into()) } @@ -321,8 +317,7 @@ impl JsonSolutionsReader { "triple" => t = Some(Type::Triple), _ => { return Err(SyntaxError::msg(format!( - "Unexpected term type: '{}'", - s + "Unexpected term type: '{s}'" )) .into()) } @@ -338,9 +333,10 @@ impl JsonSolutionsReader { state = None; } Some(State::Datatype) => { - datatype = Some(NamedNode::new(s).map_err(|e| { - SyntaxError::msg(format!("Invalid datatype IRI: {}", e)) - })?); + datatype = + Some(NamedNode::new(s).map_err(|e| { + SyntaxError::msg(format!("Invalid datatype IRI: {e}")) + })?); state = None; } _ => (), // impossible @@ -364,12 +360,12 @@ impl JsonSolutionsReader { Some(Type::Uri) => Ok(NamedNode::new(value.ok_or_else(|| { SyntaxError::msg("uri serialization should have a 'value' key") })?) - .map_err(|e| SyntaxError::msg(format!("Invalid uri value: {}", e)))? + .map_err(|e| SyntaxError::msg(format!("Invalid uri value: {e}")))? .into()), Some(Type::BNode) => Ok(BlankNode::new(value.ok_or_else(|| { SyntaxError::msg("bnode serialization should have a 'value' key") })?) - .map_err(|e| SyntaxError::msg(format!("Invalid bnode value: {}", e)))? + .map_err(|e| SyntaxError::msg(format!("Invalid bnode value: {e}")))? .into()), Some(Type::Literal) => { let value = value.ok_or_else(|| { @@ -382,13 +378,12 @@ impl JsonSolutionsReader { if let Some(datatype) = datatype { if datatype.as_ref() != rdf::LANG_STRING { return Err(SyntaxError::msg(format!( - "xml:lang value '{}' provided with the datatype {}", - lang, datatype + "xml:lang value '{lang}' provided with the datatype {datatype}" )).into()) } } Literal::new_language_tagged_literal(value, &lang).map_err(|e| { - SyntaxError::msg(format!("Invalid xml:lang value '{}': {}", lang, e)) + SyntaxError::msg(format!("Invalid xml:lang value '{lang}': {e}")) })? } None => if let Some(datatype) = datatype { @@ -465,14 +460,12 @@ fn read_head( JsonEvent::String(s) => { let new_var = Variable::new(s).map_err(|e| { SyntaxError::msg(format!( - "Invalid variable declaration '{}': {}", - s, e + "Invalid variable declaration '{s}': {e}" )) })?; if variables.contains(&new_var) { return Err(SyntaxError::msg(format!( - "The variable {} is declared twice", - new_var + "The variable {new_var} is declared twice" )) .into()); } diff --git a/lib/sparesults/src/solution.rs b/lib/sparesults/src/solution.rs index c8036e95..0d7adeff 100644 --- a/lib/sparesults/src/solution.rs +++ b/lib/sparesults/src/solution.rs @@ -142,7 +142,7 @@ impl Index for QuerySolution { #[inline] fn index(&self, index: usize) -> &Term { self.get(index) - .unwrap_or_else(|| panic!("The column {} is not set in this solution", index)) + .unwrap_or_else(|| panic!("The column {index} is not set in this solution")) } } @@ -152,7 +152,7 @@ impl Index<&str> for QuerySolution { #[inline] fn index(&self, index: &str) -> &Term { self.get(index) - .unwrap_or_else(|| panic!("The variable ?{} is not set in this solution", index)) + .unwrap_or_else(|| panic!("The variable ?{index} is not set in this solution")) } } @@ -162,7 +162,7 @@ impl Index> for QuerySolution { #[inline] fn index(&self, index: VariableRef<'_>) -> &Term { self.get(index) - .unwrap_or_else(|| panic!("The variable {} is not set in this solution", index)) + .unwrap_or_else(|| panic!("The variable {index} is not set in this solution")) } } impl Index for QuerySolution { diff --git a/lib/sparesults/src/xml.rs b/lib/sparesults/src/xml.rs index 554eac6a..10b034e5 100644 --- a/lib/sparesults/src/xml.rs +++ b/lib/sparesults/src/xml.rs @@ -195,11 +195,10 @@ impl XmlQueryResultsReader { .find(|attr| attr.key.local_name().as_ref() == b"name") .ok_or_else(|| SyntaxError::msg("No name attribute found for the tag"))? .decode_and_unescape_value(&reader)?; - let variable = Variable::new(name).map_err(|e| SyntaxError::msg(format!("Invalid variable name: {}", e)))?; + let variable = Variable::new(name).map_err(|e| SyntaxError::msg(format!("Invalid variable name: {e}")))?; if variables.contains(&variable) { return Err(SyntaxError::msg(format!( - "The variable {} is declared twice", - variable + "The variable {variable} is declared twice" )) .into()); } @@ -243,10 +242,10 @@ impl XmlQueryResultsReader { } else if value == "false" { Ok(Self::Boolean(false)) } else { - Err(SyntaxError::msg(format!("Unexpected boolean value. Found '{}'", value)).into()) + Err(SyntaxError::msg(format!("Unexpected boolean value. Found '{value}'")).into()) }; } - _ => Err(SyntaxError::msg(format!("Unexpected textual value found: '{}'", value)).into()) + _ => Err(SyntaxError::msg(format!("Unexpected textual value found: '{value}'")).into()) }; }, Event::End(event) => { @@ -365,8 +364,7 @@ impl XmlSolutionsReader { datatype = Some(NamedNode::new(iri.to_string()).map_err(|e| { SyntaxError::msg(format!( - "Invalid datatype IRI '{}': {}", - iri, e + "Invalid datatype IRI '{iri}': {e}" )) })?); } @@ -406,10 +404,7 @@ impl XmlSolutionsReader { term = Some( NamedNode::new(data.to_string()) .map_err(|e| { - SyntaxError::msg(format!( - "Invalid IRI value '{}': {}", - data, e - )) + SyntaxError::msg(format!("Invalid IRI value '{data}': {e}")) })? .into(), ) @@ -419,8 +414,7 @@ impl XmlSolutionsReader { BlankNode::new(data.to_string()) .map_err(|e| { SyntaxError::msg(format!( - "Invalid blank node value '{}': {}", - data, e + "Invalid blank node value '{data}': {e}" )) })? .into(), @@ -431,8 +425,7 @@ impl XmlSolutionsReader { } _ => { return Err(SyntaxError::msg(format!( - "Unexpected textual value found: {}", - data + "Unexpected textual value found: {data}" )) .into()); } @@ -447,7 +440,7 @@ impl XmlSolutionsReader { new_bindings[*var] = term.take() } else { return Err( - SyntaxError::msg(format!("The variable '{}' is used in a binding but not declared in the variables list", var)).into() + SyntaxError::msg(format!("The variable '{var}' is used in a binding but not declared in the variables list")).into() ); } } else { @@ -554,14 +547,13 @@ fn build_literal( if let Some(datatype) = datatype { if datatype.as_ref() != rdf::LANG_STRING { return Err(SyntaxError::msg(format!( - "xml:lang value '{}' provided with the datatype {}", - lang, datatype + "xml:lang value '{lang}' provided with the datatype {datatype}" )) .into()); } } Literal::new_language_tagged_literal(value, &lang).map_err(|e| { - SyntaxError::msg(format!("Invalid xml:lang value '{}': {}", lang, e)).into() + SyntaxError::msg(format!("Invalid xml:lang value '{lang}': {e}")).into() }) } None => Ok(if let Some(datatype) = datatype { diff --git a/lib/spargebra/src/algebra.rs b/lib/spargebra/src/algebra.rs index 1460d3c0..dd1a2f71 100644 --- a/lib/spargebra/src/algebra.rs +++ b/lib/spargebra/src/algebra.rs @@ -21,7 +21,7 @@ impl PropertyPathExpression { /// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html). pub(crate) fn fmt_sse(&self, f: &mut impl fmt::Write) -> fmt::Result { match self { - Self::NamedNode(p) => write!(f, "{}", p), + Self::NamedNode(p) => write!(f, "{p}"), Self::Reverse(p) => { write!(f, "(reverse ")?; p.fmt_sse(f)?; @@ -59,7 +59,7 @@ impl PropertyPathExpression { Self::NegatedPropertySet(p) => { write!(f, "(notoneof")?; for p in p { - write!(f, " {}", p)?; + write!(f, " {p}")?; } write!(f, ")") } @@ -71,19 +71,19 @@ impl fmt::Display for PropertyPathExpression { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::NamedNode(p) => p.fmt(f), - Self::Reverse(p) => write!(f, "^({})", p), - Self::Sequence(a, b) => write!(f, "({} / {})", a, b), - Self::Alternative(a, b) => write!(f, "({} | {})", a, b), - Self::ZeroOrMore(p) => write!(f, "({})*", p), - Self::OneOrMore(p) => write!(f, "({})+", p), - Self::ZeroOrOne(p) => write!(f, "({})?", p), + Self::Reverse(p) => write!(f, "^({p})"), + Self::Sequence(a, b) => write!(f, "({a} / {b})"), + Self::Alternative(a, b) => write!(f, "({a} | {b})"), + Self::ZeroOrMore(p) => write!(f, "({p})*"), + Self::OneOrMore(p) => write!(f, "({p})+"), + Self::ZeroOrOne(p) => write!(f, "({p})?"), Self::NegatedPropertySet(p) => { write!(f, "!(")?; for (i, c) in p.iter().enumerate() { if i > 0 { write!(f, " | ")?; } - write!(f, "{}", c)?; + write!(f, "{c}")?; } write!(f, ")") } @@ -149,9 +149,9 @@ impl Expression { /// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html). pub(crate) fn fmt_sse(&self, f: &mut impl fmt::Write) -> fmt::Result { match self { - Self::NamedNode(node) => write!(f, "{}", node), - Self::Literal(l) => write!(f, "{}", l), - Self::Variable(var) => write!(f, "{}", var), + Self::NamedNode(node) => write!(f, "{node}"), + Self::Literal(l) => write!(f, "{l}"), + Self::Variable(var) => write!(f, "{var}"), Self::Or(a, b) => fmt_sse_binary_expression(f, "||", a, b), Self::And(a, b) => fmt_sse_binary_expression(f, "&&", a, b), Self::Equal(a, b) => fmt_sse_binary_expression(f, "=", a, b), @@ -191,7 +191,7 @@ impl Expression { write!(f, ")") } Self::Bound(v) => { - write!(f, "(bound {})", v) + write!(f, "(bound {v})") } Self::If(a, b, c) => { write!(f, "(if ")?; @@ -220,52 +220,52 @@ impl fmt::Display for Expression { Self::NamedNode(node) => node.fmt(f), Self::Literal(l) => l.fmt(f), Self::Variable(var) => var.fmt(f), - Self::Or(a, b) => write!(f, "({} || {})", a, b), - Self::And(a, b) => write!(f, "({} && {})", a, b), + Self::Or(a, b) => write!(f, "({a} || {b})"), + Self::And(a, b) => write!(f, "({a} && {b})"), Self::Equal(a, b) => { - write!(f, "({} = {})", a, b) + write!(f, "({a} = {b})") } Self::SameTerm(a, b) => { - write!(f, "sameTerm({}, {})", a, b) + write!(f, "sameTerm({a}, {b})") } Self::Greater(a, b) => { - write!(f, "({} > {})", a, b) + write!(f, "({a} > {b})") } - Self::GreaterOrEqual(a, b) => write!(f, "({} >= {})", a, b), + Self::GreaterOrEqual(a, b) => write!(f, "({a} >= {b})"), Self::Less(a, b) => { - write!(f, "({} < {})", a, b) + write!(f, "({a} < {b})") } - Self::LessOrEqual(a, b) => write!(f, "({} <= {})", a, b), + Self::LessOrEqual(a, b) => write!(f, "({a} <= {b})"), Self::In(a, b) => { - write!(f, "({} IN ", a)?; + write!(f, "({a} IN ")?; write_arg_list(b, f)?; write!(f, ")") } Self::Add(a, b) => { - write!(f, "{} + {}", a, b) + write!(f, "{a} + {b}") } Self::Subtract(a, b) => { - write!(f, "{} - {}", a, b) + write!(f, "{a} - {b}") } Self::Multiply(a, b) => { - write!(f, "{} * {}", a, b) + write!(f, "{a} * {b}") } Self::Divide(a, b) => { - write!(f, "{} / {}", a, b) + write!(f, "{a} / {b}") } - Self::UnaryPlus(e) => write!(f, "+{}", e), - Self::UnaryMinus(e) => write!(f, "-{}", e), + Self::UnaryPlus(e) => write!(f, "+{e}"), + Self::UnaryMinus(e) => write!(f, "-{e}"), Self::Not(e) => match e.as_ref() { - Self::Exists(p) => write!(f, "NOT EXISTS {{ {} }}", p), - e => write!(f, "!{}", e), + Self::Exists(p) => write!(f, "NOT EXISTS {{ {p} }}"), + e => write!(f, "!{e}"), }, Self::FunctionCall(function, parameters) => { - write!(f, "{}", function)?; + write!(f, "{function}")?; write_arg_list(parameters, f) } - Self::Bound(v) => write!(f, "BOUND({})", v), - Self::Exists(p) => write!(f, "EXISTS {{ {} }}", p), - Self::If(a, b, c) => write!(f, "IF({}, {}, {})", a, b, c), + Self::Bound(v) => write!(f, "BOUND({v})"), + Self::Exists(p) => write!(f, "EXISTS {{ {p} }}"), + Self::If(a, b, c) => write!(f, "IF({a}, {b}, {c})"), Self::Coalesce(parameters) => { write!(f, "COALESCE")?; write_arg_list(parameters, f) @@ -439,7 +439,7 @@ impl Function { Self::Object => write!(f, "object"), #[cfg(feature = "rdf-star")] Self::IsTriple => write!(f, "istriple"), - Self::Custom(iri) => write!(f, "{}", iri), + Self::Custom(iri) => write!(f, "{iri}"), } } } @@ -655,7 +655,7 @@ impl GraphPattern { variable, expression, } => { - write!(f, "(extend (({} ", variable)?; + write!(f, "(extend (({variable} ")?; expression.fmt_sse(f)?; write!(f, ")) ")?; inner.fmt_sse(f)?; @@ -692,7 +692,7 @@ impl GraphPattern { if i > 0 { write!(f, " ")?; } - write!(f, "{}", v)?; + write!(f, "{v}")?; } write!(f, ") (")?; for (i, (v, a)) in aggregates.iter().enumerate() { @@ -701,7 +701,7 @@ impl GraphPattern { } write!(f, "(")?; a.fmt_sse(f)?; - write!(f, " {})", v)?; + write!(f, " {v})")?; } write!(f, ") ")?; inner.fmt_sse(f)?; @@ -713,14 +713,14 @@ impl GraphPattern { } => { write!(f, "(table (vars")?; for var in variables { - write!(f, " {}", var)?; + write!(f, " {var}")?; } write!(f, ")")?; for row in bindings { write!(f, " (row")?; for (value, var) in row.iter().zip(variables) { if let Some(value) = value { - write!(f, " ({} {})", var, value)?; + write!(f, " ({var} {value})")?; } } write!(f, ")")?; @@ -745,7 +745,7 @@ impl GraphPattern { if i > 0 { write!(f, " ")?; } - write!(f, "{}", v)?; + write!(f, "{v}")?; } write!(f, ") ")?; inner.fmt_sse(f)?; @@ -767,9 +767,9 @@ impl GraphPattern { length, } => { if let Some(length) = length { - write!(f, "(slice {} {} ", start, length)?; + write!(f, "(slice {start} {length} ")?; } else { - write!(f, "(slice {} _ ", start)?; + write!(f, "(slice {start} _ ")?; } inner.fmt_sse(f)?; write!(f, ")") @@ -783,7 +783,7 @@ impl fmt::Display for GraphPattern { match self { Self::Bgp { patterns } => { for pattern in patterns { - write!(f, "{} .", pattern)? + write!(f, "{pattern} .")? } Ok(()) } @@ -791,7 +791,7 @@ impl fmt::Display for GraphPattern { subject, path, object, - } => write!(f, "{} {} {} .", subject, path, object), + } => write!(f, "{subject} {path} {object} ."), Self::Join { left, right } => { if matches!( right.as_ref(), @@ -801,9 +801,9 @@ impl fmt::Display for GraphPattern { | Self::Filter { .. } ) { // The second block might be considered as a modification of the first one. - write!(f, "{} {{ {} }}", left, right) + write!(f, "{left} {{ {right} }}") } else { - write!(f, "{} {}", left, right) + write!(f, "{left} {right}") } } Self::LeftJoin { @@ -812,33 +812,33 @@ impl fmt::Display for GraphPattern { expression, } => { if let Some(expr) = expression { - write!(f, "{} OPTIONAL {{ {} FILTER({}) }}", left, right, expr) + write!(f, "{left} OPTIONAL {{ {right} FILTER({expr}) }}") } else { - write!(f, "{} OPTIONAL {{ {} }}", left, right) + write!(f, "{left} OPTIONAL {{ {right} }}") } } Self::Filter { expr, inner } => { - write!(f, "{} FILTER({})", inner, expr) + write!(f, "{inner} FILTER({expr})") } - Self::Union { left, right } => write!(f, "{{ {} }} UNION {{ {} }}", left, right,), + Self::Union { left, right } => write!(f, "{{ {left} }} UNION {{ {right} }}",), Self::Graph { name, inner } => { - write!(f, "GRAPH {} {{ {} }}", name, inner) + write!(f, "GRAPH {name} {{ {inner} }}") } Self::Extend { inner, variable, expression, - } => write!(f, "{} BIND({} AS {})", inner, expression, variable), - Self::Minus { left, right } => write!(f, "{} MINUS {{ {} }}", left, right), + } => write!(f, "{inner} BIND({expression} AS {variable})"), + Self::Minus { left, right } => write!(f, "{left} MINUS {{ {right} }}"), Self::Service { name, inner, silent, } => { if *silent { - write!(f, "SERVICE SILENT {} {{ {} }}", name, inner) + write!(f, "SERVICE SILENT {name} {{ {inner} }}") } else { - write!(f, "SERVICE {} {{ {} }}", name, inner) + write!(f, "SERVICE {name} {{ {inner} }}") } } Self::Values { @@ -847,14 +847,14 @@ impl fmt::Display for GraphPattern { } => { write!(f, "VALUES ( ")?; for var in variables { - write!(f, "{} ", var)?; + write!(f, "{var} ")?; } write!(f, ") {{ ")?; for row in bindings { write!(f, "( ")?; for val in row { match val { - Some(val) => write!(f, "{} ", val), + Some(val) => write!(f, "{val} "), None => write!(f, "UNDEF "), }?; } @@ -869,16 +869,16 @@ impl fmt::Display for GraphPattern { } => { write!(f, "{{SELECT")?; for (a, v) in aggregates { - write!(f, " ({} AS {})", v, a)?; + write!(f, " ({v} AS {a})")?; } for b in variables { - write!(f, " {}", b)?; + write!(f, " {b}")?; } - write!(f, " WHERE {{ {} }}", inner)?; + write!(f, " WHERE {{ {inner} }}")?; if !variables.is_empty() { write!(f, " GROUP BY")?; for v in variables { - write!(f, " {}", v)?; + write!(f, " {v}")?; } } write!(f, "}}") @@ -1062,24 +1062,24 @@ impl<'a> fmt::Display for SparqlGraphRootPattern<'a> { write!(f, " *")?; } else { for v in project { - write!(f, " {}", v)?; + write!(f, " {v}")?; } } if let Some(dataset) = self.dataset { - write!(f, " {}", dataset)?; + write!(f, " {dataset}")?; } - write!(f, " WHERE {{ {} }}", p)?; + write!(f, " WHERE {{ {p} }}")?; if let Some(order) = order { write!(f, " ORDER BY")?; for c in order { - write!(f, " {}", c)?; + write!(f, " {c}")?; } } if start > 0 { - write!(f, " OFFSET {}", start)?; + write!(f, " OFFSET {start}")?; } if let Some(length) = length { - write!(f, " LIMIT {}", length)?; + write!(f, " LIMIT {length}")?; } return Ok(()); } @@ -1210,7 +1210,7 @@ impl AggregateExpression { expr, distinct, } => { - write!(f, "({}", name)?; + write!(f, "({name}")?; if *distinct { write!(f, " distinct")?; } @@ -1228,49 +1228,49 @@ impl fmt::Display for AggregateExpression { Self::Count { expr, distinct } => { if *distinct { if let Some(expr) = expr { - write!(f, "COUNT(DISTINCT {})", expr) + write!(f, "COUNT(DISTINCT {expr})") } else { write!(f, "COUNT(DISTINCT *)") } } else if let Some(expr) = expr { - write!(f, "COUNT({})", expr) + write!(f, "COUNT({expr})") } else { write!(f, "COUNT(*)") } } Self::Sum { expr, distinct } => { if *distinct { - write!(f, "SUM(DISTINCT {})", expr) + write!(f, "SUM(DISTINCT {expr})") } else { - write!(f, "SUM({})", expr) + write!(f, "SUM({expr})") } } Self::Min { expr, distinct } => { if *distinct { - write!(f, "MIN(DISTINCT {})", expr) + write!(f, "MIN(DISTINCT {expr})") } else { - write!(f, "MIN({})", expr) + write!(f, "MIN({expr})") } } Self::Max { expr, distinct } => { if *distinct { - write!(f, "MAX(DISTINCT {})", expr) + write!(f, "MAX(DISTINCT {expr})") } else { - write!(f, "MAX({})", expr) + write!(f, "MAX({expr})") } } Self::Avg { expr, distinct } => { if *distinct { - write!(f, "AVG(DISTINCT {})", expr) + write!(f, "AVG(DISTINCT {expr})") } else { - write!(f, "AVG({})", expr) + write!(f, "AVG({expr})") } } Self::Sample { expr, distinct } => { if *distinct { - write!(f, "SAMPLE(DISTINCT {})", expr) + write!(f, "SAMPLE(DISTINCT {expr})") } else { - write!(f, "SAMPLE({})", expr) + write!(f, "SAMPLE({expr})") } } Self::GroupConcat { @@ -1287,7 +1287,7 @@ impl fmt::Display for AggregateExpression { LiteralRef::new_simple_literal(separator) ) } else { - write!(f, "GROUP_CONCAT(DISTINCT {})", expr) + write!(f, "GROUP_CONCAT(DISTINCT {expr})") } } else if let Some(separator) = separator { write!( @@ -1297,7 +1297,7 @@ impl fmt::Display for AggregateExpression { LiteralRef::new_simple_literal(separator) ) } else { - write!(f, "GROUP_CONCAT({})", expr) + write!(f, "GROUP_CONCAT({expr})") } } Self::Custom { @@ -1306,9 +1306,9 @@ impl fmt::Display for AggregateExpression { distinct, } => { if *distinct { - write!(f, "{}(DISTINCT {})", name, expr) + write!(f, "{name}(DISTINCT {expr})") } else { - write!(f, "{}({})", name, expr) + write!(f, "{name}({expr})") } } } @@ -1345,8 +1345,8 @@ impl OrderExpression { impl fmt::Display for OrderExpression { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::Asc(e) => write!(f, "ASC({})", e), - Self::Desc(e) => write!(f, "DESC({})", e), + Self::Asc(e) => write!(f, "ASC({e})"), + Self::Desc(e) => write!(f, "DESC({e})"), } } } @@ -1366,14 +1366,14 @@ impl QueryDataset { if i > 0 { write!(f, " ")?; } - write!(f, "{}", graph_name)?; + write!(f, "{graph_name}")?; } if let Some(named) = &self.named { for (i, graph_name) in named.iter().enumerate() { if !self.default.is_empty() || i > 0 { write!(f, " ")?; } - write!(f, "(named {})", graph_name)?; + write!(f, "(named {graph_name})")?; } } write!(f, ")") @@ -1383,11 +1383,11 @@ impl QueryDataset { impl fmt::Display for QueryDataset { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { for g in &self.default { - write!(f, " FROM {}", g)?; + write!(f, " FROM {g}")?; } if let Some(named) = &self.named { for g in named { - write!(f, " FROM NAMED {}", g)?; + write!(f, " FROM NAMED {g}")?; } } Ok(()) @@ -1409,7 +1409,7 @@ impl GraphTarget { /// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html). pub(crate) fn fmt_sse(&self, f: &mut impl fmt::Write) -> fmt::Result { match self { - Self::NamedNode(node) => write!(f, "{}", node), + Self::NamedNode(node) => write!(f, "{node}"), Self::DefaultGraph => write!(f, "default"), Self::NamedGraphs => write!(f, "named"), Self::AllGraphs => write!(f, "all"), @@ -1420,7 +1420,7 @@ impl GraphTarget { impl fmt::Display for GraphTarget { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::NamedNode(node) => write!(f, "GRAPH {}", node), + Self::NamedNode(node) => write!(f, "GRAPH {node}"), Self::DefaultGraph => write!(f, "DEFAULT"), Self::NamedGraphs => write!(f, "NAMED"), Self::AllGraphs => write!(f, "ALL"), @@ -1445,7 +1445,7 @@ impl From for GraphTarget { #[inline] fn fmt_sse_unary_expression(f: &mut impl fmt::Write, name: &str, e: &Expression) -> fmt::Result { - write!(f, "({} ", name)?; + write!(f, "({name} ")?; e.fmt_sse(f)?; write!(f, ")") } @@ -1457,7 +1457,7 @@ fn fmt_sse_binary_expression( a: &Expression, b: &Expression, ) -> fmt::Result { - write!(f, "({} ", name)?; + write!(f, "({name} ")?; a.fmt_sse(f)?; write!(f, " ")?; b.fmt_sse(f)?; diff --git a/lib/spargebra/src/parser.rs b/lib/spargebra/src/parser.rs index d99d4612..b7c8b3bd 100644 --- a/lib/spargebra/src/parser.rs +++ b/lib/spargebra/src/parser.rs @@ -82,7 +82,7 @@ impl fmt::Display for ParseError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match &self.inner { ParseErrorKind::InvalidBaseIri(e) => { - write!(f, "Invalid SPARQL base IRI provided: {}", e) + write!(f, "Invalid SPARQL base IRI provided: {e}") } ParseErrorKind::Parser(e) => e.fmt(f), } diff --git a/lib/spargebra/src/query.rs b/lib/spargebra/src/query.rs index bd5f6fd9..b389c85f 100644 --- a/lib/spargebra/src/query.rs +++ b/lib/spargebra/src/query.rs @@ -81,7 +81,7 @@ impl Query { base_iri, } => { if let Some(base_iri) = base_iri { - write!(f, "(base <{}> ", base_iri)?; + write!(f, "(base <{base_iri}> ")?; } if let Some(dataset) = dataset { write!(f, "(dataset ")?; @@ -104,7 +104,7 @@ impl Query { base_iri, } => { if let Some(base_iri) = base_iri { - write!(f, "(base <{}> ", base_iri)?; + write!(f, "(base <{base_iri}> ")?; } write!(f, "(construct (")?; for (i, t) in template.iter().enumerate() { @@ -135,7 +135,7 @@ impl Query { base_iri, } => { if let Some(base_iri) = base_iri { - write!(f, "(base <{}> ", base_iri)?; + write!(f, "(base <{base_iri}> ")?; } write!(f, "(describe ")?; if let Some(dataset) = dataset { @@ -159,7 +159,7 @@ impl Query { base_iri, } => { if let Some(base_iri) = base_iri { - write!(f, "(base <{}> ", base_iri)?; + write!(f, "(base <{base_iri}> ")?; } write!(f, "(ask ")?; if let Some(dataset) = dataset { @@ -190,7 +190,7 @@ impl fmt::Display for Query { base_iri, } => { if let Some(base_iri) = base_iri { - writeln!(f, "BASE <{}>", base_iri)?; + writeln!(f, "BASE <{base_iri}>")?; } write!( f, @@ -208,11 +208,11 @@ impl fmt::Display for Query { base_iri, } => { if let Some(base_iri) = base_iri { - writeln!(f, "BASE <{}>", base_iri)?; + writeln!(f, "BASE <{base_iri}>")?; } write!(f, "CONSTRUCT {{ ")?; for triple in template.iter() { - write!(f, "{} . ", triple)?; + write!(f, "{triple} . ")?; } write!(f, "}}")?; if let Some(dataset) = dataset { @@ -254,7 +254,7 @@ impl fmt::Display for Query { base_iri, } => { if let Some(base_iri) = base_iri { - writeln!(f, "BASE <{}>", base_iri)?; + writeln!(f, "BASE <{base_iri}>")?; } write!(f, "ASK")?; if let Some(dataset) = dataset { diff --git a/lib/spargebra/src/term.rs b/lib/spargebra/src/term.rs index 14af2ada..d32ec914 100644 --- a/lib/spargebra/src/term.rs +++ b/lib/spargebra/src/term.rs @@ -193,7 +193,7 @@ impl GraphName { /// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html). pub(crate) fn fmt_sse(&self, f: &mut impl Write) -> fmt::Result { match self { - Self::NamedNode(node) => write!(f, "{}", node), + Self::NamedNode(node) => write!(f, "{node}"), Self::DefaultGraph => write!(f, "default"), } } @@ -390,8 +390,8 @@ impl NamedNodePattern { /// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html). pub(crate) fn fmt_sse(&self, f: &mut impl Write) -> fmt::Result { match self { - Self::NamedNode(node) => write!(f, "{}", node), - Self::Variable(var) => write!(f, "{}", var), + Self::NamedNode(node) => write!(f, "{node}"), + Self::Variable(var) => write!(f, "{var}"), } } } @@ -447,12 +447,12 @@ impl TermPattern { /// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html). pub(crate) fn fmt_sse(&self, f: &mut impl Write) -> fmt::Result { match self { - Self::NamedNode(term) => write!(f, "{}", term), - Self::BlankNode(term) => write!(f, "{}", term), - Self::Literal(term) => write!(f, "{}", term), + Self::NamedNode(term) => write!(f, "{term}"), + Self::BlankNode(term) => write!(f, "{term}"), + Self::Literal(term) => write!(f, "{term}"), #[cfg(feature = "rdf-star")] Self::Triple(triple) => triple.fmt_sse(f), - Self::Variable(var) => write!(f, "{}", var), + Self::Variable(var) => write!(f, "{var}"), } } } @@ -465,7 +465,7 @@ impl fmt::Display for TermPattern { Self::BlankNode(term) => term.fmt(f), Self::Literal(term) => term.fmt(f), #[cfg(feature = "rdf-star")] - Self::Triple(triple) => write!(f, "<<{}>>", triple), + Self::Triple(triple) => write!(f, "<<{triple}>>"), Self::Variable(var) => var.fmt(f), } } @@ -584,9 +584,9 @@ impl GroundTermPattern { /// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html). pub(crate) fn fmt_sse(&self, f: &mut impl Write) -> fmt::Result { match self { - Self::NamedNode(term) => write!(f, "{}", term), - Self::Literal(term) => write!(f, "{}", term), - Self::Variable(var) => write!(f, "{}", var), + Self::NamedNode(term) => write!(f, "{term}"), + Self::Literal(term) => write!(f, "{term}"), + Self::Variable(var) => write!(f, "{var}"), Self::Triple(triple) => triple.fmt_sse(f), } } @@ -599,7 +599,7 @@ impl fmt::Display for GroundTermPattern { Self::NamedNode(term) => term.fmt(f), Self::Literal(term) => term.fmt(f), Self::Variable(var) => var.fmt(f), - Self::Triple(triple) => write!(f, "<<{}>>", triple), + Self::Triple(triple) => write!(f, "<<{triple}>>"), } } } @@ -692,9 +692,9 @@ impl GraphNamePattern { /// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html). pub(crate) fn fmt_sse(&self, f: &mut impl Write) -> fmt::Result { match self { - Self::NamedNode(node) => write!(f, "{}", node), + Self::NamedNode(node) => write!(f, "{node}"), Self::DefaultGraph => write!(f, "default"), - Self::Variable(var) => write!(f, "{}", var), + Self::Variable(var) => write!(f, "{var}"), } } } diff --git a/lib/spargebra/src/update.rs b/lib/spargebra/src/update.rs index 8934b134..a5079c69 100644 --- a/lib/spargebra/src/update.rs +++ b/lib/spargebra/src/update.rs @@ -41,7 +41,7 @@ impl Update { /// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html). fn fmt_sse(&self, f: &mut impl fmt::Write) -> fmt::Result { if let Some(base_iri) = &self.base_iri { - write!(f, "(base <{}> ", base_iri)?; + write!(f, "(base <{base_iri}> ")?; } write!(f, "(update")?; for op in &self.operations { @@ -59,10 +59,10 @@ impl Update { impl fmt::Display for Update { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if let Some(base_iri) = &self.base_iri { - writeln!(f, "BASE <{}>", base_iri)?; + writeln!(f, "BASE <{base_iri}>")?; } for update in &self.operations { - writeln!(f, "{} ;", update)?; + writeln!(f, "{update} ;")?; } Ok(()) } @@ -191,7 +191,7 @@ impl GraphUpdateOperation { if *silent { write!(f, "silent ")?; } - write!(f, "{} ", source)?; + write!(f, "{source} ")?; destination.fmt_sse(f)?; write!(f, ")") } @@ -208,7 +208,7 @@ impl GraphUpdateOperation { if *silent { write!(f, "silent ")?; } - write!(f, "{})", graph) + write!(f, "{graph})") } GraphUpdateOperation::Drop { silent, graph } => { write!(f, "(drop ")?; @@ -244,24 +244,24 @@ impl fmt::Display for GraphUpdateOperation { if !delete.is_empty() { writeln!(f, "DELETE {{")?; for quad in delete { - writeln!(f, "\t{} .", quad)?; + writeln!(f, "\t{quad} .")?; } writeln!(f, "}}")?; } if !insert.is_empty() { writeln!(f, "INSERT {{")?; for quad in insert { - writeln!(f, "\t{} .", quad)?; + writeln!(f, "\t{quad} .")?; } writeln!(f, "}}")?; } if let Some(using) = using { for g in &using.default { - writeln!(f, "USING {}", g)?; + writeln!(f, "USING {g}")?; } if let Some(named) = &using.named { for g in named { - writeln!(f, "USING NAMED {}", g)?; + writeln!(f, "USING NAMED {g}")?; } } } @@ -283,9 +283,9 @@ impl fmt::Display for GraphUpdateOperation { if *silent { write!(f, "SILENT ")?; } - write!(f, "{}", source)?; + write!(f, "{source}")?; if destination != &GraphName::DefaultGraph { - write!(f, " INTO GRAPH {}", destination)?; + write!(f, " INTO GRAPH {destination}")?; } Ok(()) } @@ -294,21 +294,21 @@ impl fmt::Display for GraphUpdateOperation { if *silent { write!(f, "SILENT ")?; } - write!(f, "{}", graph) + write!(f, "{graph}") } GraphUpdateOperation::Create { silent, graph } => { write!(f, "CREATE ")?; if *silent { write!(f, "SILENT ")?; } - write!(f, "GRAPH {}", graph) + write!(f, "GRAPH {graph}") } GraphUpdateOperation::Drop { silent, graph } => { write!(f, "DROP ")?; if *silent { write!(f, "SILENT ")?; } - write!(f, "{}", graph) + write!(f, "{graph}") } } } diff --git a/lib/sparql-smith/src/lib.rs b/lib/sparql-smith/src/lib.rs index 859c8a0a..1c2e57ed 100644 --- a/lib/sparql-smith/src/lib.rs +++ b/lib/sparql-smith/src/lib.rs @@ -47,7 +47,7 @@ enum QueryVariant { impl fmt::Display for Query { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match &self.variant { - QueryVariant::Select(s) => write!(f, "{}", s), + QueryVariant::Select(s) => write!(f, "{s}"), }?; write!(f, "{}", self.values_clause) } @@ -138,8 +138,8 @@ impl fmt::Display for SelectClause { SelectValues::Projection { start, others } => { for e in once(start).chain(others) { match e { - SelectProjection::Variable(v) => write!(f, " {}", v), - SelectProjection::Projection(e, v) => write!(f, " ({} AS {})", e, v), + SelectProjection::Variable(v) => write!(f, " {v}"), + SelectProjection::Projection(e, v) => write!(f, " ({e} AS {v})"), }?; } Ok(()) @@ -176,16 +176,16 @@ struct SolutionModifier { impl fmt::Display for SolutionModifier { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if let Some(group) = &self.group { - write!(f, " {}", group)?; + write!(f, " {group}")?; } if let Some(having) = &self.having { - write!(f, " {}", having)?; + write!(f, " {having}")?; } if let Some(order) = &self.order { - write!(f, " {}", order)?; + write!(f, " {order}")?; } if let Some(limit_offset) = &self.limit_offset { - write!(f, " {}", limit_offset)?; + write!(f, " {limit_offset}")?; } Ok(()) } @@ -202,7 +202,7 @@ impl fmt::Display for GroupClause { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "GROUP BY {}", self.start)?; for o in &self.others { - write!(f, " {}", o)?; + write!(f, " {o}")?; } Ok(()) } @@ -220,16 +220,16 @@ enum GroupCondition { impl fmt::Display for GroupCondition { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::BuiltInCall(c) => write!(f, "{}", c), + Self::BuiltInCall(c) => write!(f, "{c}"), //Self::FunctionCall(c) => write!(f, "{}", c), Self::Projection(e, v) => { if let Some(v) = v { - write!(f, "({} AS {})", e, v) + write!(f, "({e} AS {v})") } else { - write!(f, "({})", e) + write!(f, "({e})") } } - Self::Var(v) => write!(f, "{}", v), + Self::Var(v) => write!(f, "{v}"), } } } @@ -245,7 +245,7 @@ impl fmt::Display for HavingClause { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "HAVING {}", self.start)?; for o in &self.others { - write!(f, " {}", o)?; + write!(f, " {o}")?; } Ok(()) } @@ -265,7 +265,7 @@ impl fmt::Display for OrderClause { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "ORDER BY {}", self.start)?; for other in &self.others { - write!(f, " {}", other)?; + write!(f, " {other}")?; } Ok(()) } @@ -287,13 +287,13 @@ impl fmt::Display for OrderCondition { match self { Self::BrackettedExpression { is_asc, inner } => { if *is_asc { - write!(f, "ASC{}", inner) + write!(f, "ASC{inner}") } else { - write!(f, "DESC{}", inner) + write!(f, "DESC{inner}") } } - Self::Constraint(c) => write!(f, "{}", c), - Self::Var(v) => write!(f, "{}", v), + Self::Constraint(c) => write!(f, "{c}"), + Self::Var(v) => write!(f, "{v}"), } } } @@ -308,10 +308,10 @@ enum LimitOffsetClauses { impl fmt::Display for LimitOffsetClauses { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::LimitOffset(l, Some(o)) => write!(f, "{} {}", l, o), - Self::LimitOffset(l, None) => write!(f, "{}", l), - Self::OffsetLimit(o, Some(l)) => write!(f, "{} {}", o, l), - Self::OffsetLimit(o, None) => write!(f, "{}", o), + Self::LimitOffset(l, Some(o)) => write!(f, "{l} {o}"), + Self::LimitOffset(l, None) => write!(f, "{l}"), + Self::OffsetLimit(o, Some(l)) => write!(f, "{o} {l}"), + Self::OffsetLimit(o, None) => write!(f, "{o}"), } } } @@ -349,7 +349,7 @@ struct ValuesClause { impl fmt::Display for ValuesClause { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if let Some(value) = &self.value { - write!(f, " VALUES {}", value) + write!(f, " VALUES {value}") } else { Ok(()) } @@ -367,8 +367,8 @@ impl fmt::Display for GroupGraphPattern { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, " {{ ")?; match self { - Self::GroupGraphPatternSub(p) => write!(f, "{}", p), - Self::SubSelect(s) => write!(f, "{}", s), + Self::GroupGraphPatternSub(p) => write!(f, "{p}"), + Self::SubSelect(s) => write!(f, "{s}"), }?; write!(f, " }} ") } @@ -391,7 +391,7 @@ struct GroupGraphPatternSubOtherBlock { impl fmt::Display for GroupGraphPatternSub { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if let Some(start) = &self.start { - write!(f, "{}", start)?; + write!(f, "{start}")?; } for other in &self.others { write!(f, "{}", other.start)?; @@ -399,7 +399,7 @@ impl fmt::Display for GroupGraphPatternSub { write!(f, " . ")?; } if let Some(end) = &other.end { - write!(f, "{}", end)?; + write!(f, "{end}")?; } } Ok(()) @@ -419,7 +419,7 @@ impl fmt::Display for TriplesBlock { if let Some(end) = &self.end { write!(f, " . ")?; if let Some(end) = end { - write!(f, "{}", end)?; + write!(f, "{end}")?; } } Ok(()) @@ -441,13 +441,13 @@ enum GraphPatternNotTriples { impl fmt::Display for GraphPatternNotTriples { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::GroupOrUnion(p) => write!(f, "{}", p), - Self::Optional(p) => write!(f, "{}", p), - Self::Minus(p) => write!(f, "{}", p), - Self::Graph(p) => write!(f, "{}", p), - Self::Filter(p) => write!(f, "{}", p), - Self::Bind(p) => write!(f, "{}", p), - Self::InlineData(p) => write!(f, "{}", p), + Self::GroupOrUnion(p) => write!(f, "{p}"), + Self::Optional(p) => write!(f, "{p}"), + Self::Minus(p) => write!(f, "{p}"), + Self::Graph(p) => write!(f, "{p}"), + Self::Filter(p) => write!(f, "{p}"), + Self::Bind(p) => write!(f, "{p}"), + Self::InlineData(p) => write!(f, "{p}"), } } } @@ -512,8 +512,8 @@ enum DataBlock { impl fmt::Display for DataBlock { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::OneVar(e) => write!(f, "{}", e), - Self::Full(c) => write!(f, "{}", c), + Self::OneVar(e) => write!(f, "{e}"), + Self::Full(c) => write!(f, "{c}"), } } } @@ -529,7 +529,7 @@ impl fmt::Display for InlineDataOneVar { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{} {{", self.var)?; for v in &self.values { - write!(f, " {}", v)?; + write!(f, " {v}")?; } write!(f, " }}") } @@ -569,13 +569,13 @@ impl fmt::Display for InlineDataFull { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "( ")?; for v in &self.vars { - write!(f, " {}", v)?; + write!(f, " {v}")?; } write!(f, " ) {{")?; for vs in &self.values { write!(f, " (")?; for v in vs { - write!(f, " {}", v)?; + write!(f, " {v}")?; } write!(f, " )")?; } @@ -594,8 +594,8 @@ enum DataBlockValue { impl fmt::Display for DataBlockValue { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::Iri(i) => write!(f, "{}", i), - Self::Literal(l) => write!(f, "{}", l), + Self::Iri(i) => write!(f, "{i}"), + Self::Literal(l) => write!(f, "{l}"), Self::Undef => write!(f, "UNDEF"), } } @@ -624,7 +624,7 @@ impl fmt::Display for GroupOrUnionGraphPattern { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.start)?; for other in &self.others { - write!(f, " UNION {}", other)?; + write!(f, " UNION {other}")?; } Ok(()) } @@ -653,8 +653,8 @@ enum Constraint { impl fmt::Display for Constraint { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::BrackettedExpression(e) => write!(f, "{}", e), - Self::BuiltInCall(c) => write!(f, "{}", c), + Self::BrackettedExpression(e) => write!(f, "{e}"), + Self::BuiltInCall(c) => write!(f, "{c}"), //Self::FunctionCall(c) => write!(f, "{}", c), } } @@ -688,9 +688,9 @@ impl fmt::Display for ArgList { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "(")?; if let Self::NotNil { start, others } = self { - write!(f, "{}", start)?; + write!(f, "{start}")?; for e in others { - write!(f, ", {}", e)?; + write!(f, ", {e}")?; } } write!(f, ")") @@ -710,7 +710,7 @@ impl fmt::Display for ExpressionList { if i > 0 { write!(f, ", ")?; } - write!(f, "{}", e)?; + write!(f, "{e}")?; } write!(f, ")") } @@ -753,7 +753,7 @@ enum Verb { impl fmt::Display for Verb { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::VarOrIri(iri) => write!(f, "{}", iri), + Self::VarOrIri(iri) => write!(f, "{iri}"), Self::A => write!(f, " a "), } } @@ -771,7 +771,7 @@ impl fmt::Display for ObjectList { write!(f, "{}", self.start)?; for other in &self.others { write!(f, " , ")?; - write!(f, "{}", other)?; + write!(f, "{other}")?; } Ok(()) } @@ -800,13 +800,13 @@ impl fmt::Display for TriplesSameSubjectPath { subject, predicate_object, } => { - write!(f, "{}{}", subject, predicate_object) + write!(f, "{subject}{predicate_object}") } Self::Other { subject, predicate_object, } => { - write!(f, "{} {}", subject, predicate_object) + write!(f, "{subject} {predicate_object}") } } } @@ -821,7 +821,7 @@ struct PropertyListPath { impl fmt::Display for PropertyListPath { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if let Some(p) = &self.inner { - write!(f, "{}", p) + write!(f, "{p}") } else { Ok(()) } @@ -851,16 +851,16 @@ struct PropertyListPathElement { impl fmt::Display for PropertyListPathNotEmpty { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match &self.start_predicate { - PropertyListPathNotEmptyVerb::VerbPath(p) => write!(f, "{}", p), - PropertyListPathNotEmptyVerb::VerbSimple(s) => write!(f, "{}", s), + PropertyListPathNotEmptyVerb::VerbPath(p) => write!(f, "{p}"), + PropertyListPathNotEmptyVerb::VerbSimple(s) => write!(f, "{s}"), }?; write!(f, "{}", self.start_object)?; for other in &self.others { write!(f, " ; ")?; if let Some(e) = other { match &e.predicate { - PropertyListPathNotEmptyVerb::VerbPath(p) => write!(f, "{}", p), - PropertyListPathNotEmptyVerb::VerbSimple(s) => write!(f, "{}", s), + PropertyListPathNotEmptyVerb::VerbPath(p) => write!(f, "{p}"), + PropertyListPathNotEmptyVerb::VerbSimple(s) => write!(f, "{s}"), }?; write!(f, "{}", e.object)?; } @@ -886,7 +886,7 @@ impl fmt::Display for ObjectListPath { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.start)?; for other in &self.others { - write!(f, " , {}", other)?; + write!(f, " , {other}")?; } Ok(()) } @@ -909,7 +909,7 @@ impl fmt::Display for PathAlternative { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.start)?; for other in &self.others { - write!(f, " | {}", other)?; + write!(f, " | {other}")?; } Ok(()) } @@ -926,7 +926,7 @@ impl fmt::Display for PathSequence { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.start)?; for other in &self.others { - write!(f, " / {}", other)?; + write!(f, " / {other}")?; } Ok(()) } @@ -943,7 +943,7 @@ impl fmt::Display for PathElt { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.path)?; if let Some(mode) = &self.mode { - write!(f, "{}", mode)?; + write!(f, "{mode}")?; } Ok(()) } @@ -959,8 +959,8 @@ enum PathEltOrInverse { impl fmt::Display for PathEltOrInverse { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::PathElt(e) => write!(f, "{}", e), - Self::Inverse(e) => write!(f, " ^{}", e), + Self::PathElt(e) => write!(f, "{e}"), + Self::Inverse(e) => write!(f, " ^{e}"), } } } @@ -995,10 +995,10 @@ enum PathPrimary { impl fmt::Display for PathPrimary { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::Iri(iri) => write!(f, "{}", iri), + Self::Iri(iri) => write!(f, "{iri}"), Self::A => write!(f, " a "), - Self::Negated(n) => write!(f, "!{}", n), - Self::Child(c) => write!(f, "({})", c), + Self::Negated(n) => write!(f, "!{n}"), + Self::Child(c) => write!(f, "({c})"), } } } @@ -1016,11 +1016,11 @@ enum PathNegatedPropertySet { impl fmt::Display for PathNegatedPropertySet { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::Single(p) => write!(f, "{}", p), + Self::Single(p) => write!(f, "{p}"), Self::Multiple { start, others } => { - write!(f, " ( {}", start)?; + write!(f, " ( {start}")?; for other in others { - write!(f, " | {}", other)?; + write!(f, " | {other}")?; } write!(f, " ) ") } @@ -1040,9 +1040,9 @@ enum PathOneInPropertySet { impl fmt::Display for PathOneInPropertySet { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::Iri(iri) => write!(f, "{}", iri), + Self::Iri(iri) => write!(f, "{iri}"), Self::A => write!(f, " a "), - Self::NegatedIri(iri) => write!(f, "^{}", iri), + Self::NegatedIri(iri) => write!(f, "^{iri}"), Self::NegatedA => write!(f, " ^a "), } } @@ -1058,8 +1058,8 @@ enum TriplesNode { impl fmt::Display for TriplesNode { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::Collection(p) => write!(f, "{}", p), - Self::BlankNodePropertyList(p) => write!(f, "{}", p), + Self::Collection(p) => write!(f, "{p}"), + Self::BlankNodePropertyList(p) => write!(f, "{p}"), } } } @@ -1086,8 +1086,8 @@ enum TriplesNodePath { impl fmt::Display for TriplesNodePath { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::CollectionPath(p) => write!(f, "{}", p), - Self::BlankNodePropertyListPath(p) => write!(f, "{}", p), + Self::CollectionPath(p) => write!(f, "{p}"), + Self::BlankNodePropertyListPath(p) => write!(f, "{p}"), } } } @@ -1115,7 +1115,7 @@ impl fmt::Display for Collection { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "( {}", self.start)?; for e in &self.others { - write!(f, " {}", e)?; + write!(f, " {e}")?; } write!(f, " )") } @@ -1132,7 +1132,7 @@ impl fmt::Display for CollectionPath { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "( {}", self.start)?; for e in &self.others { - write!(f, " {}", e)?; + write!(f, " {e}")?; } write!(f, " )") } @@ -1148,8 +1148,8 @@ enum GraphNode { impl fmt::Display for GraphNode { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::VarOrTerm(t) => write!(f, "{}", t), - Self::TriplesNode(t) => write!(f, "{}", t), + Self::VarOrTerm(t) => write!(f, "{t}"), + Self::TriplesNode(t) => write!(f, "{t}"), } } } @@ -1164,8 +1164,8 @@ enum GraphNodePath { impl fmt::Display for GraphNodePath { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::VarOrTerm(t) => write!(f, "{}", t), - Self::TriplesNodePath(p) => write!(f, "{}", p), + Self::VarOrTerm(t) => write!(f, "{t}"), + Self::TriplesNodePath(p) => write!(f, "{p}"), } } } @@ -1180,8 +1180,8 @@ enum VarOrTerm { impl fmt::Display for VarOrTerm { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::Var(v) => write!(f, "{}", v), - Self::GraphTerm(t) => write!(f, "{}", t), + Self::Var(v) => write!(f, "{v}"), + Self::GraphTerm(t) => write!(f, "{t}"), } } } @@ -1196,8 +1196,8 @@ enum VarOrIri { impl fmt::Display for VarOrIri { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::Var(v) => write!(f, "{}", v), - Self::Iri(t) => write!(f, "{}", t), + Self::Var(v) => write!(f, "{v}"), + Self::Iri(t) => write!(f, "{t}"), } } } @@ -1238,8 +1238,8 @@ enum GraphTerm { impl fmt::Display for GraphTerm { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::Iri(iri) => write!(f, "{}", iri), - Self::Literal(l) => write!(f, "{}", l), + Self::Iri(iri) => write!(f, "{iri}"), + Self::Literal(l) => write!(f, "{l}"), Self::Nil => write!(f, " () "), } } @@ -1259,7 +1259,7 @@ impl fmt::Display for ConditionalOrExpression { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.start)?; for e in &self.others { - write!(f, " || {}", e)?; + write!(f, " || {e}")?; } Ok(()) } @@ -1276,7 +1276,7 @@ impl fmt::Display for ConditionalAndExpression { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.start)?; for e in &self.others { - write!(f, " && {}", e)?; + write!(f, " && {e}")?; } Ok(()) } @@ -1302,15 +1302,15 @@ enum RelationalExpression { impl fmt::Display for RelationalExpression { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::Base(e) => write!(f, "{}", e), - Self::Equal(a, b) => write!(f, "{} = {}", a, b), - Self::NotEqual(a, b) => write!(f, "{} != {}", a, b), - Self::Less(a, b) => write!(f, "{} < {}", a, b), - Self::LessOrEqual(a, b) => write!(f, "{} <= {}", a, b), - Self::Greater(a, b) => write!(f, "{} > {}", a, b), - Self::GreaterOrEqual(a, b) => write!(f, "{} >= {}", a, b), - Self::In(a, b) => write!(f, "{} IN {}", a, b), - Self::NotIn(a, b) => write!(f, "{} NOT IN {}", a, b), + Self::Base(e) => write!(f, "{e}"), + Self::Equal(a, b) => write!(f, "{a} = {b}"), + Self::NotEqual(a, b) => write!(f, "{a} != {b}"), + Self::Less(a, b) => write!(f, "{a} < {b}"), + Self::LessOrEqual(a, b) => write!(f, "{a} <= {b}"), + Self::Greater(a, b) => write!(f, "{a} > {b}"), + Self::GreaterOrEqual(a, b) => write!(f, "{a} >= {b}"), + Self::In(a, b) => write!(f, "{a} IN {b}"), + Self::NotIn(a, b) => write!(f, "{a} NOT IN {b}"), } } } @@ -1329,9 +1329,9 @@ enum AdditiveExpression { impl fmt::Display for AdditiveExpression { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::Base(e) => write!(f, "{}", e), - Self::Plus(a, b) => write!(f, "{} + {}", a, b), - Self::Minus(a, b) => write!(f, "{} - {}", a, b), + Self::Base(e) => write!(f, "{e}"), + Self::Plus(a, b) => write!(f, "{a} + {b}"), + Self::Minus(a, b) => write!(f, "{a} - {b}"), } } } @@ -1347,9 +1347,9 @@ enum MultiplicativeExpression { impl fmt::Display for MultiplicativeExpression { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::Base(e) => write!(f, "{}", e), - Self::Mul(a, b) => write!(f, "{} * {}", a, b), - Self::Div(a, b) => write!(f, "{} / {}", a, b), + Self::Base(e) => write!(f, "{e}"), + Self::Mul(a, b) => write!(f, "{a} * {b}"), + Self::Div(a, b) => write!(f, "{a} / {b}"), } } } @@ -1366,10 +1366,10 @@ enum UnaryExpression { impl fmt::Display for UnaryExpression { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::Not(e) => write!(f, "!{}", e), - Self::Plus(e) => write!(f, "+{}", e), - Self::Minus(e) => write!(f, "-{}", e), - Self::Base(e) => write!(f, "{}", e), + Self::Not(e) => write!(f, "!{e}"), + Self::Plus(e) => write!(f, "+{e}"), + Self::Minus(e) => write!(f, "-{e}"), + Self::Base(e) => write!(f, "{e}"), } } } @@ -1387,11 +1387,11 @@ enum PrimaryExpression { impl fmt::Display for PrimaryExpression { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::Bracketted(e) => write!(f, "{}", e), - Self::BuiltInCall(e) => write!(f, "{}", e), - Self::IriOrFunction(e) => write!(f, "{}", e), - Self::Literal(e) => write!(f, "{}", e), - Self::Var(e) => write!(f, "{}", e), + Self::Bracketted(e) => write!(f, "{e}"), + Self::BuiltInCall(e) => write!(f, "{e}"), + Self::IriOrFunction(e) => write!(f, "{e}"), + Self::Literal(e) => write!(f, "{e}"), + Self::Var(e) => write!(f, "{e}"), } } } @@ -1473,9 +1473,9 @@ enum BuiltInCall { impl fmt::Display for BuiltInCall { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::Bound(v) => write!(f, "BOUND({})", v), - Self::Exists(e) => write!(f, "{}", e), - Self::NotExists(e) => write!(f, "{}", e), + Self::Bound(v) => write!(f, "BOUND({v})"), + Self::Exists(e) => write!(f, "{e}"), + Self::NotExists(e) => write!(f, "{e}"), } } } diff --git a/lib/src/io/error.rs b/lib/src/io/error.rs index 52c009ad..5584169b 100644 --- a/lib/src/io/error.rs +++ b/lib/src/io/error.rs @@ -119,7 +119,7 @@ impl fmt::Display for SyntaxError { SyntaxErrorKind::Turtle(e) => e.fmt(f), SyntaxErrorKind::RdfXml(e) => e.fmt(f), SyntaxErrorKind::InvalidBaseIri { iri, error } => { - write!(f, "Invalid base IRI '{}': {}", iri, error) + write!(f, "Invalid base IRI '{iri}': {error}") } } } @@ -144,7 +144,7 @@ impl From for io::Error { SyntaxErrorKind::RdfXml(error) => error.into(), SyntaxErrorKind::InvalidBaseIri { iri, error } => Self::new( io::ErrorKind::InvalidInput, - format!("Invalid IRI '{}': {}", iri, error), + format!("Invalid IRI '{iri}': {error}"), ), } } diff --git a/lib/src/io/write.rs b/lib/src/io/write.rs index af4ebaf0..56eebca6 100644 --- a/lib/src/io/write.rs +++ b/lib/src/io/write.rs @@ -89,7 +89,7 @@ impl TripleWriter { let triple = triple.into(); match &mut self.formatter { TripleWriterKind::NTriples(writer) => { - writeln!(writer, "{} .", triple)?; + writeln!(writer, "{triple} .")?; } TripleWriterKind::RdfXml(formatter) => formatter.format(&rio::Triple { subject: match triple.subject { @@ -233,7 +233,7 @@ impl QuadWriter { let quad = quad.into(); match &mut self.formatter { QuadWriterKind::NQuads(writer) => { - writeln!(writer, "{} .", quad)?; + writeln!(writer, "{quad} .")?; } QuadWriterKind::TriG(writer) => { if quad.graph_name == GraphNameRef::DefaultGraph { @@ -244,7 +244,7 @@ impl QuadWriter { TripleRef::from(quad) )?; } else { - writeln!(writer, "{} .", quad)?; + writeln!(writer, "{quad} .")?; } } } diff --git a/lib/src/sparql/error.rs b/lib/src/sparql/error.rs index ce629c34..101b0165 100644 --- a/lib/src/sparql/error.rs +++ b/lib/src/sparql/error.rs @@ -53,7 +53,7 @@ impl fmt::Display for QueryError { #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match &self.inner { - QueryErrorKind::Msg { msg } => write!(f, "{}", msg), + QueryErrorKind::Msg { msg } => write!(f, "{msg}"), QueryErrorKind::Other(error) => error.fmt(f), } } diff --git a/lib/src/sparql/eval.rs b/lib/src/sparql/eval.rs index 66d76d79..06cd4302 100644 --- a/lib/src/sparql/eval.rs +++ b/lib/src/sparql/eval.rs @@ -4437,7 +4437,6 @@ fn uuid() { Regex::new("^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$") .unwrap() .is_match(&buffer), - "{} is not a valid UUID", - buffer + "{buffer} is not a valid UUID" ); } diff --git a/lib/src/sparql/http/simple.rs b/lib/src/sparql/http/simple.rs index 4f89b900..57b9e540 100644 --- a/lib/src/sparql/http/simple.rs +++ b/lib/src/sparql/http/simple.rs @@ -39,7 +39,7 @@ impl Client { } let content_type = response .header(&HeaderName::CONTENT_TYPE) - .ok_or_else(|| invalid_data_error(format!("No Content-Type returned by {}", url)))? + .ok_or_else(|| invalid_data_error(format!("No Content-Type returned by {url}")))? .to_str() .map_err(invalid_data_error)? .to_owned(); @@ -74,7 +74,7 @@ impl Client { } let content_type = response .header(&HeaderName::CONTENT_TYPE) - .ok_or_else(|| invalid_data_error(format!("No Content-Type returned by {}", url)))? + .ok_or_else(|| invalid_data_error(format!("No Content-Type returned by {url}")))? .to_str() .map_err(invalid_data_error)? .to_owned(); diff --git a/lib/src/sparql/plan_builder.rs b/lib/src/sparql/plan_builder.rs index d3cfc198..46d6d0c3 100644 --- a/lib/src/sparql/plan_builder.rs +++ b/lib/src/sparql/plan_builder.rs @@ -754,8 +754,7 @@ impl<'a> PlanBuilder<'a> { )? } else { return Err(EvaluationError::msg(format!( - "Not supported custom function {}", - expression + "Not supported custom function {expression}" ))); } } @@ -796,8 +795,7 @@ impl<'a> PlanBuilder<'a> { )?))) } else { Err(EvaluationError::msg(format!( - "The xsd:{} casting takes only one parameter", - name + "The xsd:{name} casting takes only one parameter" ))) } } diff --git a/lib/src/sparql/service.rs b/lib/src/sparql/service.rs index e1394eb0..b92337e3 100644 --- a/lib/src/sparql/service.rs +++ b/lib/src/sparql/service.rs @@ -120,8 +120,7 @@ impl ServiceHandler for SimpleServiceHandler { )?; let format = QueryResultsFormat::from_media_type(&content_type).ok_or_else(|| { EvaluationError::msg(format!( - "Unsupported Content-Type returned by {}: {}", - service_name, content_type + "Unsupported Content-Type returned by {service_name}: {content_type}" )) })?; Ok(QueryResults::read(BufReader::new(body), format)?) diff --git a/lib/src/sparql/update.rs b/lib/src/sparql/update.rs index 0cfe8888..314f43f3 100644 --- a/lib/src/sparql/update.rs +++ b/lib/src/sparql/update.rs @@ -161,8 +161,7 @@ impl<'a, 'b: 'a> SimpleUpdateEvaluator<'a, 'b> { )?; let format = GraphFormat::from_media_type(&content_type).ok_or_else(|| { EvaluationError::msg(format!( - "Unsupported Content-Type returned by {}: {}", - from, content_type + "Unsupported Content-Type returned by {from}: {content_type}" )) })?; let to_graph_name = match to { @@ -187,8 +186,7 @@ impl<'a, 'b: 'a> SimpleUpdateEvaluator<'a, 'b> { Ok(()) } else { Err(EvaluationError::msg(format!( - "The graph {} already exists", - graph_name + "The graph {graph_name} already exists" ))) } } @@ -206,8 +204,7 @@ impl<'a, 'b: 'a> SimpleUpdateEvaluator<'a, 'b> { Ok(()) } else { Err(EvaluationError::msg(format!( - "The graph {} does not exists", - graph + "The graph {graph} does not exists" ))) } } @@ -227,8 +224,7 @@ impl<'a, 'b: 'a> SimpleUpdateEvaluator<'a, 'b> { Ok(()) } else { Err(EvaluationError::msg(format!( - "The graph {} does not exists", - graph_name + "The graph {graph_name} does not exists" ))) } } diff --git a/lib/src/storage/backend/rocksdb.rs b/lib/src/storage/backend/rocksdb.rs index 5a5570b8..706c5f85 100644 --- a/lib/src/storage/backend/rocksdb.rs +++ b/lib/src/storage/backend/rocksdb.rs @@ -175,8 +175,8 @@ impl Db { return Err(io::Error::new( io::ErrorKind::Other, format!( - "Oxigraph needs at least 96 file descriptors, only {} allowed. Run e.g. `ulimit -n 512` to allow 512 opened files", - available_fd + "Oxigraph needs at least 96 file descriptors, only {available_fd} allowed. Run e.g. `ulimit -n 512` to allow 512 opened files" + ), ) .into()); @@ -1123,7 +1123,7 @@ fn path_to_cstring(path: &Path) -> Result { .map_err(|e| { io::Error::new( io::ErrorKind::InvalidInput, - format!("The DB path contains null bytes: {}", e), + format!("The DB path contains null bytes: {e}"), ) })?) } diff --git a/lib/src/storage/mod.rs b/lib/src/storage/mod.rs index 6b27dec2..8685d880 100644 --- a/lib/src/storage/mod.rs +++ b/lib/src/storage/mod.rs @@ -200,13 +200,13 @@ impl Storage { match version { _ if version < LATEST_STORAGE_VERSION => Err(CorruptionError::msg(format!( - "The RocksDB database is using the outdated encoding version {}. Automated migration is not supported, please dump the store dataset using a compatible Oxigraph version and load it again using the current version", - version + "The RocksDB database is using the outdated encoding version {version}. Automated migration is not supported, please dump the store dataset using a compatible Oxigraph version and load it again using the current version" + )).into()), LATEST_STORAGE_VERSION => Ok(()), _ => Err(CorruptionError::msg(format!( - "The RocksDB database is using the too recent version {}. Upgrade to the latest Oxigraph version to load this database", - version + "The RocksDB database is using the too recent version {version}. Upgrade to the latest Oxigraph version to load this database" + )).into()) } } @@ -216,7 +216,7 @@ impl Storage { Ok( if let Some(version) = self.db.get(&self.default_cf, b"oxversion")? { u64::from_be_bytes(version.as_ref().try_into().map_err(|e| { - CorruptionError::new(format!("Error while parsing the version key: {}", e)) + CorruptionError::new(format!("Error while parsing the version key: {e}")) })?) } else { self.update_version(LATEST_STORAGE_VERSION)?; diff --git a/lib/src/storage/numeric_encoder.rs b/lib/src/storage/numeric_encoder.rs index 5b5e0099..bd1d561b 100644 --- a/lib/src/storage/numeric_encoder.rs +++ b/lib/src/storage/numeric_encoder.rs @@ -987,8 +987,7 @@ impl Decoder for S { fn get_required_str(lookup: &L, id: &StrHash) -> Result { Ok(lookup.get_str(id)?.ok_or_else(|| { CorruptionError::new(format!( - "Not able to find the string with id {:?} in the string store", - id + "Not able to find the string with id {id:?} in the string store" )) })?) } diff --git a/lib/src/storage/small_string.rs b/lib/src/storage/small_string.rs index 4f8f8cf0..4bb1520b 100644 --- a/lib/src/storage/small_string.rs +++ b/lib/src/storage/small_string.rs @@ -184,8 +184,7 @@ impl fmt::Display for BadSmallStringError { match self { Self::TooLong(v) => write!( f, - "small strings could only contain at most 15 characters, found {}", - v + "small strings could only contain at most 15 characters, found {v}" ), Self::BadUtf8(e) => e.fmt(f), } diff --git a/lib/src/xsd/date_time.rs b/lib/src/xsd/date_time.rs index 3694bffe..810ab223 100644 --- a/lib/src/xsd/date_time.rs +++ b/lib/src/xsd/date_time.rs @@ -217,7 +217,7 @@ impl fmt::Display for DateTime { self.second() )?; if let Some(timezone_offset) = self.timezone_offset() { - write!(f, "{}", timezone_offset)?; + write!(f, "{timezone_offset}")?; } Ok(()) } @@ -372,7 +372,7 @@ impl fmt::Display for Time { self.second() )?; if let Some(timezone_offset) = self.timezone_offset() { - write!(f, "{}", timezone_offset)?; + write!(f, "{timezone_offset}")?; } Ok(()) } @@ -522,7 +522,7 @@ impl fmt::Display for Date { } write!(f, "{:04}-{:02}-{:02}", year.abs(), self.month(), self.day())?; if let Some(timezone_offset) = self.timezone_offset() { - write!(f, "{}", timezone_offset)?; + write!(f, "{timezone_offset}")?; } Ok(()) } @@ -622,7 +622,7 @@ impl fmt::Display for GYearMonth { } write!(f, "{:04}-{:02}", year.abs(), self.month())?; if let Some(timezone_offset) = self.timezone_offset() { - write!(f, "{}", timezone_offset)?; + write!(f, "{timezone_offset}")?; } Ok(()) } @@ -721,7 +721,7 @@ impl fmt::Display for GYear { } write!(f, "{:04}", year.abs())?; if let Some(timezone_offset) = self.timezone_offset() { - write!(f, "{}", timezone_offset)?; + write!(f, "{timezone_offset}")?; } Ok(()) } @@ -817,7 +817,7 @@ impl fmt::Display for GMonthDay { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "--{:02}-{:02}", self.month(), self.day())?; if let Some(timezone_offset) = self.timezone_offset() { - write!(f, "{}", timezone_offset)?; + write!(f, "{timezone_offset}")?; } Ok(()) } @@ -920,7 +920,7 @@ impl fmt::Display for GMonth { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "--{:02}", self.month())?; if let Some(timezone_offset) = self.timezone_offset() { - write!(f, "{}", timezone_offset)?; + write!(f, "{timezone_offset}")?; } Ok(()) } @@ -1015,7 +1015,7 @@ impl fmt::Display for GDay { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "---{:02}", self.day())?; if let Some(timezone_offset) = self.timezone_offset() { - write!(f, "{}", timezone_offset)?; + write!(f, "{timezone_offset}")?; } Ok(()) } @@ -1514,7 +1514,7 @@ impl fmt::Display for DateTimeError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match &self.kind { DateTimeErrorKind::InvalidDayOfMonth { day, month } => { - write!(f, "{} is not a valid day of {}", day, month) + write!(f, "{day} is not a valid day of {month}") } DateTimeErrorKind::Overflow => write!(f, "Overflow during date time normalization"), DateTimeErrorKind::SystemTime(error) => error.fmt(f), diff --git a/lib/src/xsd/duration.rs b/lib/src/xsd/duration.rs index d5fbae3b..4d2bae3a 100644 --- a/lib/src/xsd/duration.rs +++ b/lib/src/xsd/duration.rs @@ -134,12 +134,12 @@ impl fmt::Display for Duration { if y != 0 { if m == 0 { - write!(f, "{}Y", y)?; + write!(f, "{y}Y")?; } else { - write!(f, "{}Y{}M", y, m)?; + write!(f, "{y}Y{m}M")?; } } else if m != 0 || ss == 0.into() { - write!(f, "{}M", m)?; + write!(f, "{m}M")?; } } @@ -153,19 +153,19 @@ impl fmt::Display for Duration { .unwrap(); //could not fail if d != 0 { - write!(f, "{}D", d)?; + write!(f, "{d}D")?; } if h != 0 || m != 0 || s != 0.into() { write!(f, "T")?; if h != 0 { - write!(f, "{}H", h)?; + write!(f, "{h}H")?; } if m != 0 { - write!(f, "{}M", m)?; + write!(f, "{m}M")?; } if s != 0.into() { - write!(f, "{}S", s)?; + write!(f, "{s}S")?; } } } diff --git a/lib/src/xsd/parser.rs b/lib/src/xsd/parser.rs index 087c539d..a519fa68 100644 --- a/lib/src/xsd/parser.rs +++ b/lib/src/xsd/parser.rs @@ -41,29 +41,27 @@ impl fmt::Display for XsdParseError { write!(f, "Invalid XML Schema value: {}", kind.description()) } XsdParseErrorKind::NomChar(c) => { - write!(f, "Unexpected character in XML Schema value: '{}'", c) + write!(f, "Unexpected character in XML Schema value: '{c}'") } XsdParseErrorKind::MissingData(Needed::Unknown) => { write!(f, "Too small XML Schema value") } XsdParseErrorKind::MissingData(Needed::Size(size)) => { - write!(f, "Too small XML Schema value: missing {} chars", size) + write!(f, "Too small XML Schema value: missing {size} chars") } XsdParseErrorKind::TooMuchData { count } => { - write!(f, "Too long XML Schema value: {} extra chars", count) + write!(f, "Too long XML Schema value: {count} extra chars") } XsdParseErrorKind::Overflow => write!(f, "Computation overflow or underflow"), XsdParseErrorKind::ParseInt(error) => { - write!(f, "Error while parsing integer: {}", error) + write!(f, "Error while parsing integer: {error}") } XsdParseErrorKind::ParseDecimal(error) => { - write!(f, "Error while parsing decimal: {}", error) + write!(f, "Error while parsing decimal: {error}") + } + XsdParseErrorKind::OutOfIntegerRange { value, min, max } => { + write!(f, "The integer {value} is not between {min} and {max}") } - XsdParseErrorKind::OutOfIntegerRange { value, min, max } => write!( - f, - "The integer {} is not between {} and {}", - value, min, max - ), XsdParseErrorKind::DateTime(error) => error.fmt(f), } } diff --git a/oxrocksdb-sys/build.rs b/oxrocksdb-sys/build.rs index 79a34bec..a2605cd6 100644 --- a/oxrocksdb-sys/build.rs +++ b/oxrocksdb-sys/build.rs @@ -8,7 +8,7 @@ fn link(name: &str, bundled: bool) { let target = var("TARGET").unwrap(); let target: Vec<_> = target.split('-').collect(); if target.get(2) == Some(&"windows") { - println!("cargo:rustc-link-lib=dylib={}", name); + println!("cargo:rustc-link-lib=dylib={name}"); if bundled && target.get(3) == Some(&"gnu") { let dir = var("CARGO_MANIFEST_DIR").unwrap(); println!("cargo:rustc-link-search=native={}/{}", dir, target[0]); diff --git a/python/src/io.rs b/python/src/io.rs index 568330b8..38667825 100644 --- a/python/src/io.rs +++ b/python/src/io.rs @@ -83,8 +83,7 @@ pub fn parse( .into_py(py)) } else { Err(PyValueError::new_err(format!( - "Not supported MIME type: {}", - mime_type + "Not supported MIME type: {mime_type}" ))) } } @@ -150,8 +149,7 @@ pub fn serialize(input: &PyAny, output: PyObject, mime_type: &str, py: Python<'_ Ok(()) } else { Err(PyValueError::new_err(format!( - "Not supported MIME type: {}", - mime_type + "Not supported MIME type: {mime_type}" ))) } } diff --git a/python/src/store.rs b/python/src/store.rs index a9fabf15..b73972da 100644 --- a/python/src/store.rs +++ b/python/src/store.rs @@ -324,8 +324,7 @@ impl PyStore { .map_err(map_loader_error) } else { Err(PyValueError::new_err(format!( - "Not supported MIME type: {}", - mime_type + "Not supported MIME type: {mime_type}" ))) } }) @@ -411,8 +410,7 @@ impl PyStore { .map_err(map_loader_error) } else { Err(PyValueError::new_err(format!( - "Not supported MIME type: {}", - mime_type + "Not supported MIME type: {mime_type}" ))) } }) @@ -488,8 +486,7 @@ impl PyStore { .map_err(map_serializer_error) } else { Err(PyValueError::new_err(format!( - "Not supported MIME type: {}", - mime_type + "Not supported MIME type: {mime_type}" ))) } }) diff --git a/server/src/main.rs b/server/src/main.rs index a2bc1a46..addfd0a7 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -76,7 +76,7 @@ pub fn main() -> anyhow::Result<()> { Command::Load { file, lenient } => { ThreadPoolBuilder::new() .num_threads(max(1, available_parallelism()?.get() / 2)) - .thread_name(|i| format!("Oxigraph bulk loader thread {}", i)) + .thread_name(|i| format!("Oxigraph bulk loader thread {i}")) .build()? .scope(|s| { for file in file { @@ -177,8 +177,7 @@ impl GraphOrDatasetFormat { if let Some(ext) = path.extension().and_then(|ext| ext.to_str()) { Self::from_extension(ext).map_err(|e| { e.context(format!( - "Not able to guess the file format from file name extension '{}'", - ext + "Not able to guess the file format from file name extension '{ext}'" )) }) } else { @@ -416,7 +415,7 @@ fn handle_request(request: &mut Request, store: Store) -> Result( let (possible, parameters) = possible.split_once(';').unwrap_or((possible, "")); let (possible_base, possible_sub) = possible .split_once('/') - .ok_or_else(|| bad_request(format!("Invalid media type: '{}'", possible)))?; + .ok_or_else(|| bad_request(format!("Invalid media type: '{possible}'")))?; let possible_base = possible_base.trim(); let possible_sub = possible_sub.trim(); @@ -856,7 +855,7 @@ fn content_negotiation( let parameter = parameter.trim(); if let Some(s) = parameter.strip_prefix("q=") { score = f32::from_str(s.trim()) - .map_err(|_| bad_request(format!("Invalid Accept media type score: {}", s)))? + .map_err(|_| bad_request(format!("Invalid Accept media type score: {s}")))? } } if score <= result_score { @@ -868,7 +867,7 @@ fn content_negotiation( .map_or(*candidate, |(p, _)| p) .split_once('/') .ok_or_else(|| { - internal_server_error(format!("Invalid media type: '{}'", possible)) + internal_server_error(format!("Invalid media type: '{possible}'")) })?; if (possible_base == candidate_base || possible_base == "*") && (possible_sub == candidate_sub || possible_sub == "*") @@ -955,7 +954,7 @@ fn web_bulk_loader(store: &Store, request: &Request) -> BulkLoader { }); if url_query_parameter(request, "lenient").is_some() { loader = loader.on_parse_error(move |e| { - eprintln!("Parsing error: {}", e); + eprintln!("Parsing error: {e}"); Ok(()) }) } @@ -976,12 +975,12 @@ fn bad_request(message: impl fmt::Display) -> HttpError { fn unsupported_media_type(content_type: &str) -> HttpError { ( Status::UNSUPPORTED_MEDIA_TYPE, - format!("No supported content Content-Type given: {}", content_type), + format!("No supported content Content-Type given: {content_type}"), ) } fn internal_server_error(message: impl fmt::Display) -> HttpError { - eprintln!("Internal server error: {}", message); + eprintln!("Internal server error: {message}"); (Status::INTERNAL_SERVER_ERROR, message.to_string()) } @@ -1033,7 +1032,7 @@ impl io::Result>)> Read for ReadForWrite { self.state = match (self.add_more_data)(state) { Ok(state) => state, Err(e) => { - eprintln!("Internal server error while streaming results: {}", e); + eprintln!("Internal server error while streaming results: {e}"); self.buffer .borrow_mut() .write_all(e.to_string().as_bytes())?; @@ -1721,7 +1720,7 @@ mod tests { let mut response = self.exec(request); let mut buf = String::new(); response.body_mut().read_to_string(&mut buf)?; - assert_eq!(response.status(), expected_status, "Error message: {}", buf); + assert_eq!(response.status(), expected_status, "Error message: {buf}"); Ok(()) } @@ -1729,7 +1728,7 @@ mod tests { let mut response = self.exec(request); let mut buf = String::new(); response.body_mut().read_to_string(&mut buf)?; - assert_eq!(response.status(), Status::OK, "Error message: {}", buf); + assert_eq!(response.status(), Status::OK, "Error message: {buf}"); assert_eq!(&buf, expected_body); Ok(()) } diff --git a/testsuite/src/manifest.rs b/testsuite/src/manifest.rs index 2a76cd5f..be3ee5a8 100644 --- a/testsuite/src/manifest.rs +++ b/testsuite/src/manifest.rs @@ -25,25 +25,25 @@ impl fmt::Display for Test { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.kind)?; for name in &self.name { - write!(f, " named \"{}\"", name)?; + write!(f, " named \"{name}\"")?; } for comment in &self.comment { - write!(f, " with comment \"{}\"", comment)?; + write!(f, " with comment \"{comment}\"")?; } if let Some(action) = &self.action { - write!(f, " on file \"{}\"", action)?; + write!(f, " on file \"{action}\"")?; } if let Some(query) = &self.query { write!(f, " on query {}", &query)?; } for data in &self.data { - write!(f, " with data {}", data)?; + write!(f, " with data {data}")?; } for (_, data) in &self.graph_data { - write!(f, " and graph data {}", data)?; + write!(f, " and graph data {data}")?; } for result in &self.result { - write!(f, " and expected result {}", result)?; + write!(f, " and expected result {result}")?; } Ok(()) } diff --git a/testsuite/src/parser_evaluator.rs b/testsuite/src/parser_evaluator.rs index 35216f6c..70cffd89 100644 --- a/testsuite/src/parser_evaluator.rs +++ b/testsuite/src/parser_evaluator.rs @@ -70,7 +70,7 @@ fn evaluate_positive_syntax_test(test: &Test) -> Result<()> { .ok_or_else(|| anyhow!("No action found for test {}", test))?; match load_dataset(action) { Ok(_) => Ok(()), - Err(e) => Err(anyhow!(format!("Parse error: {}", e))), + Err(e) => Err(anyhow!(format!("Parse error: {e}"))), } } diff --git a/testsuite/src/sparql_evaluator.rs b/testsuite/src/sparql_evaluator.rs index acd81261..e217201b 100644 --- a/testsuite/src/sparql_evaluator.rs +++ b/testsuite/src/sparql_evaluator.rs @@ -414,7 +414,7 @@ impl ServiceHandler for StaticServiceHandler { .ok_or_else(|| { io::Error::new( io::ErrorKind::InvalidInput, - format!("Service {} not found", service_name), + format!("Service {service_name} not found"), ) })? .query_opt( @@ -579,12 +579,12 @@ impl fmt::Display for StaticQueryResults { } => { write!(f, "Variables:")?; for v in variables { - write!(f, " {}", v)?; + write!(f, " {v}")?; } for solution in solutions { write!(f, "\n{{")?; for (k, v) in solution { - write!(f, "{} = {} ", k, v)?; + write!(f, "{k} = {v} ")?; } write!(f, "}}")?; }