String formatting: uses inline syntax

pull/332/head
Tpt 2 years ago committed by Thomas Tanon
parent f21ab0ea6a
commit 808c9db007
  1. 7
      lib/benches/store.rs
  2. 2
      lib/oxrdf/src/blank_node.rs
  3. 6
      lib/oxrdf/src/dataset.rs
  4. 4
      lib/oxrdf/src/literal.rs
  5. 26
      lib/oxrdf/src/parser.rs
  6. 4
      lib/oxrdf/src/triple.rs
  7. 10
      lib/sparesults/src/csv.rs
  8. 35
      lib/sparesults/src/json.rs
  9. 6
      lib/sparesults/src/solution.rs
  10. 30
      lib/sparesults/src/xml.rs
  11. 190
      lib/spargebra/src/algebra.rs
  12. 2
      lib/spargebra/src/parser.rs
  13. 16
      lib/spargebra/src/query.rs
  14. 28
      lib/spargebra/src/term.rs
  15. 28
      lib/spargebra/src/update.rs
  16. 232
      lib/sparql-smith/src/lib.rs
  17. 4
      lib/src/io/error.rs
  18. 6
      lib/src/io/write.rs
  19. 2
      lib/src/sparql/error.rs
  20. 3
      lib/src/sparql/eval.rs
  21. 4
      lib/src/sparql/http/simple.rs
  22. 6
      lib/src/sparql/plan_builder.rs
  23. 3
      lib/src/sparql/service.rs
  24. 12
      lib/src/sparql/update.rs
  25. 6
      lib/src/storage/backend/rocksdb.rs
  26. 10
      lib/src/storage/mod.rs
  27. 3
      lib/src/storage/numeric_encoder.rs
  28. 3
      lib/src/storage/small_string.rs
  29. 18
      lib/src/xsd/date_time.rs
  30. 14
      lib/src/xsd/duration.rs
  31. 18
      lib/src/xsd/parser.rs
  32. 2
      oxrocksdb-sys/build.rs
  33. 6
      python/src/io.rs
  34. 9
      python/src/store.rs
  35. 25
      server/src/main.rs
  36. 12
      testsuite/src/manifest.rs
  37. 2
      testsuite/src/parser_evaluator.rs
  38. 6
      testsuite/src/sparql_evaluator.rs

@ -102,7 +102,7 @@ fn store_query_and_update(c: &mut Criterion) {
match kind { match kind {
"query" => Operation::Query(Query::parse(operation, None).unwrap()), "query" => Operation::Query(Query::parse(operation, None).unwrap()),
"update" => Operation::Update(Update::parse(operation, None).unwrap()), "update" => Operation::Update(Update::parse(operation, None).unwrap()),
_ => panic!("Unexpected operation kind {}", kind), _ => panic!("Unexpected operation kind {kind}"),
} }
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();
@ -169,10 +169,7 @@ fn read_data(file: &str) -> impl BufRead {
if !Path::new(file).exists() { if !Path::new(file).exists() {
let mut client = oxhttp::Client::new(); let mut client = oxhttp::Client::new();
client.set_redirection_limit(5); client.set_redirection_limit(5);
let url = format!( let url = format!("https://github.com/Tpt/bsbm-tools/releases/download/v0.2/{file}");
"https://github.com/Tpt/bsbm-tools/releases/download/v0.2/{}",
file
);
let request = Request::builder(Method::GET, url.parse().unwrap()).build(); let request = Request::builder(Method::GET, url.parse().unwrap()).build();
let response = client.request(request).unwrap(); let response = client.request(request).unwrap();
assert_eq!( assert_eq!(

@ -251,7 +251,7 @@ impl IdStr {
#[inline] #[inline]
fn new(id: u128) -> Self { fn new(id: u128) -> Self {
let mut str = [0; 32]; let mut str = [0; 32];
write!(&mut str[..], "{:x}", id).unwrap(); write!(&mut str[..], "{id:x}").unwrap();
Self(str) Self(str)
} }

@ -901,7 +901,7 @@ impl<'a, T: Into<QuadRef<'a>>> Extend<T> for Dataset {
impl fmt::Display for Dataset { impl fmt::Display for Dataset {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
for t in self { for t in self {
writeln!(f, "{}", t)?; writeln!(f, "{t}")?;
} }
Ok(()) Ok(())
} }
@ -1236,7 +1236,7 @@ impl<'a, 'b> IntoIterator for &'b GraphView<'a> {
impl<'a> fmt::Display for GraphView<'a> { impl<'a> fmt::Display for GraphView<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
for t in self { for t in self {
writeln!(f, "{}", t)?; writeln!(f, "{t}")?;
} }
Ok(()) Ok(())
} }
@ -1438,7 +1438,7 @@ impl<'a> IntoIterator for &'a GraphViewMut<'a> {
impl<'a> fmt::Display for GraphViewMut<'a> { impl<'a> fmt::Display for GraphViewMut<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
for t in self { for t in self {
writeln!(f, "{}", t)?; writeln!(f, "{t}")?;
} }
Ok(()) Ok(())
} }

@ -440,11 +440,11 @@ impl fmt::Display for LiteralRef<'_> {
LiteralRefContent::String(value) => print_quoted_str(value, f), LiteralRefContent::String(value) => print_quoted_str(value, f),
LiteralRefContent::LanguageTaggedString { value, language } => { LiteralRefContent::LanguageTaggedString { value, language } => {
print_quoted_str(value, f)?; print_quoted_str(value, f)?;
write!(f, "@{}", language) write!(f, "@{language}")
} }
LiteralRefContent::TypedLiteral { value, datatype } => { LiteralRefContent::TypedLiteral { value, datatype } => {
print_quoted_str(value, f)?; print_quoted_str(value, f)?;
write!(f, "^^{}", datatype) write!(f, "^^{datatype}")
} }
} }
} }

@ -410,23 +410,17 @@ impl fmt::Display for TermParseError {
#[inline] #[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match &self.kind { match &self.kind {
TermParseErrorKind::Iri { error, value } => write!( TermParseErrorKind::Iri { error, value } => {
f, write!(f, "Error while parsing the named node '{value}': {error}")
"Error while parsing the named node '{}': {}", }
value, error TermParseErrorKind::BlankNode { error, value } => {
), write!(f, "Error while parsing the blank node '{value}': {error}")
TermParseErrorKind::BlankNode { error, value } => write!( }
f, TermParseErrorKind::LanguageTag { error, value } => {
"Error while parsing the blank node '{}': {}", write!(f, "Error while parsing the language tag '{value}': {error}")
value, error }
),
TermParseErrorKind::LanguageTag { error, value } => write!(
f,
"Error while parsing the language tag '{}': {}",
value, error
),
TermParseErrorKind::Variable { error, value } => { 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), TermParseErrorKind::Msg { msg } => f.write_str(msg),
} }

@ -308,7 +308,7 @@ impl fmt::Display for SubjectRef<'_> {
Self::NamedNode(node) => node.fmt(f), Self::NamedNode(node) => node.fmt(f),
Self::BlankNode(node) => node.fmt(f), Self::BlankNode(node) => node.fmt(f),
#[cfg(feature = "rdf-star")] #[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), Self::Literal(literal) => literal.fmt(f),
#[cfg(feature = "rdf-star")] #[cfg(feature = "rdf-star")]
Self::Triple(triple) => { Self::Triple(triple) => {
write!(f, "<<{}>>", triple) write!(f, "<<{triple}>>")
} }
} }
} }

@ -210,14 +210,12 @@ impl<R: BufRead> TsvQueryResultsReader<R> {
for v in buffer.split('\t') { for v in buffer.split('\t') {
let v = v.trim(); let v = v.trim();
let variable = Variable::from_str(v).map_err(|e| { 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) { if variables.contains(&variable) {
return Err(SyntaxError::msg(format!( return Err(
"The variable {} is declared twice", SyntaxError::msg(format!("The variable {variable} is declared twice")).into(),
variable );
))
.into());
} }
variables.push(variable); variables.push(variable);
} }

@ -198,8 +198,7 @@ impl<R: BufRead> JsonQueryResultsReader<R> {
} }
_ => { _ => {
return Err(SyntaxError::msg(format!( return Err(SyntaxError::msg(format!(
"Expecting head or result key, found {}", "Expecting head or result key, found {key}"
key
)) ))
.into()); .into());
} }
@ -239,8 +238,7 @@ impl<R: BufRead> JsonSolutionsReader<R> {
JsonEvent::ObjectKey(key) => { JsonEvent::ObjectKey(key) => {
let k = *self.mapping.get(key).ok_or_else(|| { let k = *self.mapping.get(key).ok_or_else(|| {
SyntaxError::msg(format!( SyntaxError::msg(format!(
"The variable {} has not been defined in the header", "The variable {key} has not been defined in the header"
key
)) ))
})?; })?;
new_bindings[k] = Some(self.read_value(0)?) new_bindings[k] = Some(self.read_value(0)?)
@ -253,8 +251,7 @@ impl<R: BufRead> JsonSolutionsReader<R> {
fn read_value(&mut self, number_of_recursive_calls: usize) -> Result<Term, ParseError> { fn read_value(&mut self, number_of_recursive_calls: usize) -> Result<Term, ParseError> {
if number_of_recursive_calls == MAX_NUMBER_OF_NESTED_TRIPLES { if number_of_recursive_calls == MAX_NUMBER_OF_NESTED_TRIPLES {
return Err(SyntaxError::msg(format!( return Err(SyntaxError::msg(format!(
"Too many nested triples ({}). The parser fails here to avoid a stack overflow.", "Too many nested triples ({MAX_NUMBER_OF_NESTED_TRIPLES}). The parser fails here to avoid a stack overflow."
MAX_NUMBER_OF_NESTED_TRIPLES
)) ))
.into()); .into());
} }
@ -297,8 +294,7 @@ impl<R: BufRead> JsonSolutionsReader<R> {
"object" => object = Some(self.read_value(number_of_recursive_calls + 1)?), "object" => object = Some(self.read_value(number_of_recursive_calls + 1)?),
_ => { _ => {
return Err(SyntaxError::msg(format!( return Err(SyntaxError::msg(format!(
"Unexpected key in term serialization: '{}'", "Unexpected key in term serialization: '{key}'"
key
)) ))
.into()) .into())
} }
@ -321,8 +317,7 @@ impl<R: BufRead> JsonSolutionsReader<R> {
"triple" => t = Some(Type::Triple), "triple" => t = Some(Type::Triple),
_ => { _ => {
return Err(SyntaxError::msg(format!( return Err(SyntaxError::msg(format!(
"Unexpected term type: '{}'", "Unexpected term type: '{s}'"
s
)) ))
.into()) .into())
} }
@ -338,8 +333,9 @@ impl<R: BufRead> JsonSolutionsReader<R> {
state = None; state = None;
} }
Some(State::Datatype) => { Some(State::Datatype) => {
datatype = Some(NamedNode::new(s).map_err(|e| { datatype =
SyntaxError::msg(format!("Invalid datatype IRI: {}", e)) Some(NamedNode::new(s).map_err(|e| {
SyntaxError::msg(format!("Invalid datatype IRI: {e}"))
})?); })?);
state = None; state = None;
} }
@ -364,12 +360,12 @@ impl<R: BufRead> JsonSolutionsReader<R> {
Some(Type::Uri) => Ok(NamedNode::new(value.ok_or_else(|| { Some(Type::Uri) => Ok(NamedNode::new(value.ok_or_else(|| {
SyntaxError::msg("uri serialization should have a 'value' key") 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()), .into()),
Some(Type::BNode) => Ok(BlankNode::new(value.ok_or_else(|| { Some(Type::BNode) => Ok(BlankNode::new(value.ok_or_else(|| {
SyntaxError::msg("bnode serialization should have a 'value' key") 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()), .into()),
Some(Type::Literal) => { Some(Type::Literal) => {
let value = value.ok_or_else(|| { let value = value.ok_or_else(|| {
@ -382,13 +378,12 @@ impl<R: BufRead> JsonSolutionsReader<R> {
if let Some(datatype) = datatype { if let Some(datatype) = datatype {
if datatype.as_ref() != rdf::LANG_STRING { if datatype.as_ref() != rdf::LANG_STRING {
return Err(SyntaxError::msg(format!( return Err(SyntaxError::msg(format!(
"xml:lang value '{}' provided with the datatype {}", "xml:lang value '{lang}' provided with the datatype {datatype}"
lang, datatype
)).into()) )).into())
} }
} }
Literal::new_language_tagged_literal(value, &lang).map_err(|e| { 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 { None => if let Some(datatype) = datatype {
@ -465,14 +460,12 @@ fn read_head<R: BufRead>(
JsonEvent::String(s) => { JsonEvent::String(s) => {
let new_var = Variable::new(s).map_err(|e| { let new_var = Variable::new(s).map_err(|e| {
SyntaxError::msg(format!( SyntaxError::msg(format!(
"Invalid variable declaration '{}': {}", "Invalid variable declaration '{s}': {e}"
s, e
)) ))
})?; })?;
if variables.contains(&new_var) { if variables.contains(&new_var) {
return Err(SyntaxError::msg(format!( return Err(SyntaxError::msg(format!(
"The variable {} is declared twice", "The variable {new_var} is declared twice"
new_var
)) ))
.into()); .into());
} }

@ -142,7 +142,7 @@ impl Index<usize> for QuerySolution {
#[inline] #[inline]
fn index(&self, index: usize) -> &Term { fn index(&self, index: usize) -> &Term {
self.get(index) 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] #[inline]
fn index(&self, index: &str) -> &Term { fn index(&self, index: &str) -> &Term {
self.get(index) 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<VariableRef<'_>> for QuerySolution {
#[inline] #[inline]
fn index(&self, index: VariableRef<'_>) -> &Term { fn index(&self, index: VariableRef<'_>) -> &Term {
self.get(index) 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<Variable> for QuerySolution { impl Index<Variable> for QuerySolution {

@ -195,11 +195,10 @@ impl<R: BufRead> XmlQueryResultsReader<R> {
.find(|attr| attr.key.local_name().as_ref() == b"name") .find(|attr| attr.key.local_name().as_ref() == b"name")
.ok_or_else(|| SyntaxError::msg("No name attribute found for the <variable> tag"))? .ok_or_else(|| SyntaxError::msg("No name attribute found for the <variable> tag"))?
.decode_and_unescape_value(&reader)?; .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) { if variables.contains(&variable) {
return Err(SyntaxError::msg(format!( return Err(SyntaxError::msg(format!(
"The variable {} is declared twice", "The variable {variable} is declared twice"
variable
)) ))
.into()); .into());
} }
@ -243,10 +242,10 @@ impl<R: BufRead> XmlQueryResultsReader<R> {
} else if value == "false" { } else if value == "false" {
Ok(Self::Boolean(false)) Ok(Self::Boolean(false))
} else { } 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) => { Event::End(event) => {
@ -365,8 +364,7 @@ impl<R: BufRead> XmlSolutionsReader<R> {
datatype = datatype =
Some(NamedNode::new(iri.to_string()).map_err(|e| { Some(NamedNode::new(iri.to_string()).map_err(|e| {
SyntaxError::msg(format!( SyntaxError::msg(format!(
"Invalid datatype IRI '{}': {}", "Invalid datatype IRI '{iri}': {e}"
iri, e
)) ))
})?); })?);
} }
@ -406,10 +404,7 @@ impl<R: BufRead> XmlSolutionsReader<R> {
term = Some( term = Some(
NamedNode::new(data.to_string()) NamedNode::new(data.to_string())
.map_err(|e| { .map_err(|e| {
SyntaxError::msg(format!( SyntaxError::msg(format!("Invalid IRI value '{data}': {e}"))
"Invalid IRI value '{}': {}",
data, e
))
})? })?
.into(), .into(),
) )
@ -419,8 +414,7 @@ impl<R: BufRead> XmlSolutionsReader<R> {
BlankNode::new(data.to_string()) BlankNode::new(data.to_string())
.map_err(|e| { .map_err(|e| {
SyntaxError::msg(format!( SyntaxError::msg(format!(
"Invalid blank node value '{}': {}", "Invalid blank node value '{data}': {e}"
data, e
)) ))
})? })?
.into(), .into(),
@ -431,8 +425,7 @@ impl<R: BufRead> XmlSolutionsReader<R> {
} }
_ => { _ => {
return Err(SyntaxError::msg(format!( return Err(SyntaxError::msg(format!(
"Unexpected textual value found: {}", "Unexpected textual value found: {data}"
data
)) ))
.into()); .into());
} }
@ -447,7 +440,7 @@ impl<R: BufRead> XmlSolutionsReader<R> {
new_bindings[*var] = term.take() new_bindings[*var] = term.take()
} else { } else {
return Err( 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 { } else {
@ -554,14 +547,13 @@ fn build_literal(
if let Some(datatype) = datatype { if let Some(datatype) = datatype {
if datatype.as_ref() != rdf::LANG_STRING { if datatype.as_ref() != rdf::LANG_STRING {
return Err(SyntaxError::msg(format!( return Err(SyntaxError::msg(format!(
"xml:lang value '{}' provided with the datatype {}", "xml:lang value '{lang}' provided with the datatype {datatype}"
lang, datatype
)) ))
.into()); .into());
} }
} }
Literal::new_language_tagged_literal(value, &lang).map_err(|e| { 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 { None => Ok(if let Some(datatype) = datatype {

@ -21,7 +21,7 @@ impl PropertyPathExpression {
/// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html). /// 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 { pub(crate) fn fmt_sse(&self, f: &mut impl fmt::Write) -> fmt::Result {
match self { match self {
Self::NamedNode(p) => write!(f, "{}", p), Self::NamedNode(p) => write!(f, "{p}"),
Self::Reverse(p) => { Self::Reverse(p) => {
write!(f, "(reverse ")?; write!(f, "(reverse ")?;
p.fmt_sse(f)?; p.fmt_sse(f)?;
@ -59,7 +59,7 @@ impl PropertyPathExpression {
Self::NegatedPropertySet(p) => { Self::NegatedPropertySet(p) => {
write!(f, "(notoneof")?; write!(f, "(notoneof")?;
for p in p { for p in p {
write!(f, " {}", p)?; write!(f, " {p}")?;
} }
write!(f, ")") write!(f, ")")
} }
@ -71,19 +71,19 @@ impl fmt::Display for PropertyPathExpression {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Self::NamedNode(p) => p.fmt(f), Self::NamedNode(p) => p.fmt(f),
Self::Reverse(p) => write!(f, "^({})", p), Self::Reverse(p) => write!(f, "^({p})"),
Self::Sequence(a, b) => write!(f, "({} / {})", a, b), Self::Sequence(a, b) => write!(f, "({a} / {b})"),
Self::Alternative(a, b) => write!(f, "({} | {})", a, b), Self::Alternative(a, b) => write!(f, "({a} | {b})"),
Self::ZeroOrMore(p) => write!(f, "({})*", p), Self::ZeroOrMore(p) => write!(f, "({p})*"),
Self::OneOrMore(p) => write!(f, "({})+", p), Self::OneOrMore(p) => write!(f, "({p})+"),
Self::ZeroOrOne(p) => write!(f, "({})?", p), Self::ZeroOrOne(p) => write!(f, "({p})?"),
Self::NegatedPropertySet(p) => { Self::NegatedPropertySet(p) => {
write!(f, "!(")?; write!(f, "!(")?;
for (i, c) in p.iter().enumerate() { for (i, c) in p.iter().enumerate() {
if i > 0 { if i > 0 {
write!(f, " | ")?; write!(f, " | ")?;
} }
write!(f, "{}", c)?; write!(f, "{c}")?;
} }
write!(f, ")") write!(f, ")")
} }
@ -149,9 +149,9 @@ impl Expression {
/// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html). /// 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 { pub(crate) fn fmt_sse(&self, f: &mut impl fmt::Write) -> fmt::Result {
match self { match self {
Self::NamedNode(node) => write!(f, "{}", node), Self::NamedNode(node) => write!(f, "{node}"),
Self::Literal(l) => write!(f, "{}", l), Self::Literal(l) => write!(f, "{l}"),
Self::Variable(var) => write!(f, "{}", var), Self::Variable(var) => write!(f, "{var}"),
Self::Or(a, b) => fmt_sse_binary_expression(f, "||", a, b), Self::Or(a, b) => fmt_sse_binary_expression(f, "||", a, b),
Self::And(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), Self::Equal(a, b) => fmt_sse_binary_expression(f, "=", a, b),
@ -191,7 +191,7 @@ impl Expression {
write!(f, ")") write!(f, ")")
} }
Self::Bound(v) => { Self::Bound(v) => {
write!(f, "(bound {})", v) write!(f, "(bound {v})")
} }
Self::If(a, b, c) => { Self::If(a, b, c) => {
write!(f, "(if ")?; write!(f, "(if ")?;
@ -220,52 +220,52 @@ impl fmt::Display for Expression {
Self::NamedNode(node) => node.fmt(f), Self::NamedNode(node) => node.fmt(f),
Self::Literal(l) => l.fmt(f), Self::Literal(l) => l.fmt(f),
Self::Variable(var) => var.fmt(f), Self::Variable(var) => var.fmt(f),
Self::Or(a, b) => write!(f, "({} || {})", a, b), Self::Or(a, b) => write!(f, "({a} || {b})"),
Self::And(a, b) => write!(f, "({} && {})", a, b), Self::And(a, b) => write!(f, "({a} && {b})"),
Self::Equal(a, b) => { Self::Equal(a, b) => {
write!(f, "({} = {})", a, b) write!(f, "({a} = {b})")
} }
Self::SameTerm(a, b) => { Self::SameTerm(a, b) => {
write!(f, "sameTerm({}, {})", a, b) write!(f, "sameTerm({a}, {b})")
} }
Self::Greater(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) => { 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) => { Self::In(a, b) => {
write!(f, "({} IN ", a)?; write!(f, "({a} IN ")?;
write_arg_list(b, f)?; write_arg_list(b, f)?;
write!(f, ")") write!(f, ")")
} }
Self::Add(a, b) => { Self::Add(a, b) => {
write!(f, "{} + {}", a, b) write!(f, "{a} + {b}")
} }
Self::Subtract(a, b) => { Self::Subtract(a, b) => {
write!(f, "{} - {}", a, b) write!(f, "{a} - {b}")
} }
Self::Multiply(a, b) => { Self::Multiply(a, b) => {
write!(f, "{} * {}", a, b) write!(f, "{a} * {b}")
} }
Self::Divide(a, b) => { Self::Divide(a, b) => {
write!(f, "{} / {}", a, b) write!(f, "{a} / {b}")
} }
Self::UnaryPlus(e) => write!(f, "+{}", e), Self::UnaryPlus(e) => write!(f, "+{e}"),
Self::UnaryMinus(e) => write!(f, "-{}", e), Self::UnaryMinus(e) => write!(f, "-{e}"),
Self::Not(e) => match e.as_ref() { Self::Not(e) => match e.as_ref() {
Self::Exists(p) => write!(f, "NOT EXISTS {{ {} }}", p), Self::Exists(p) => write!(f, "NOT EXISTS {{ {p} }}"),
e => write!(f, "!{}", e), e => write!(f, "!{e}"),
}, },
Self::FunctionCall(function, parameters) => { Self::FunctionCall(function, parameters) => {
write!(f, "{}", function)?; write!(f, "{function}")?;
write_arg_list(parameters, f) write_arg_list(parameters, f)
} }
Self::Bound(v) => write!(f, "BOUND({})", v), Self::Bound(v) => write!(f, "BOUND({v})"),
Self::Exists(p) => write!(f, "EXISTS {{ {} }}", p), Self::Exists(p) => write!(f, "EXISTS {{ {p} }}"),
Self::If(a, b, c) => write!(f, "IF({}, {}, {})", a, b, c), Self::If(a, b, c) => write!(f, "IF({a}, {b}, {c})"),
Self::Coalesce(parameters) => { Self::Coalesce(parameters) => {
write!(f, "COALESCE")?; write!(f, "COALESCE")?;
write_arg_list(parameters, f) write_arg_list(parameters, f)
@ -439,7 +439,7 @@ impl Function {
Self::Object => write!(f, "object"), Self::Object => write!(f, "object"),
#[cfg(feature = "rdf-star")] #[cfg(feature = "rdf-star")]
Self::IsTriple => write!(f, "istriple"), Self::IsTriple => write!(f, "istriple"),
Self::Custom(iri) => write!(f, "{}", iri), Self::Custom(iri) => write!(f, "{iri}"),
} }
} }
} }
@ -655,7 +655,7 @@ impl GraphPattern {
variable, variable,
expression, expression,
} => { } => {
write!(f, "(extend (({} ", variable)?; write!(f, "(extend (({variable} ")?;
expression.fmt_sse(f)?; expression.fmt_sse(f)?;
write!(f, ")) ")?; write!(f, ")) ")?;
inner.fmt_sse(f)?; inner.fmt_sse(f)?;
@ -692,7 +692,7 @@ impl GraphPattern {
if i > 0 { if i > 0 {
write!(f, " ")?; write!(f, " ")?;
} }
write!(f, "{}", v)?; write!(f, "{v}")?;
} }
write!(f, ") (")?; write!(f, ") (")?;
for (i, (v, a)) in aggregates.iter().enumerate() { for (i, (v, a)) in aggregates.iter().enumerate() {
@ -701,7 +701,7 @@ impl GraphPattern {
} }
write!(f, "(")?; write!(f, "(")?;
a.fmt_sse(f)?; a.fmt_sse(f)?;
write!(f, " {})", v)?; write!(f, " {v})")?;
} }
write!(f, ") ")?; write!(f, ") ")?;
inner.fmt_sse(f)?; inner.fmt_sse(f)?;
@ -713,14 +713,14 @@ impl GraphPattern {
} => { } => {
write!(f, "(table (vars")?; write!(f, "(table (vars")?;
for var in variables { for var in variables {
write!(f, " {}", var)?; write!(f, " {var}")?;
} }
write!(f, ")")?; write!(f, ")")?;
for row in bindings { for row in bindings {
write!(f, " (row")?; write!(f, " (row")?;
for (value, var) in row.iter().zip(variables) { for (value, var) in row.iter().zip(variables) {
if let Some(value) = value { if let Some(value) = value {
write!(f, " ({} {})", var, value)?; write!(f, " ({var} {value})")?;
} }
} }
write!(f, ")")?; write!(f, ")")?;
@ -745,7 +745,7 @@ impl GraphPattern {
if i > 0 { if i > 0 {
write!(f, " ")?; write!(f, " ")?;
} }
write!(f, "{}", v)?; write!(f, "{v}")?;
} }
write!(f, ") ")?; write!(f, ") ")?;
inner.fmt_sse(f)?; inner.fmt_sse(f)?;
@ -767,9 +767,9 @@ impl GraphPattern {
length, length,
} => { } => {
if let Some(length) = length { if let Some(length) = length {
write!(f, "(slice {} {} ", start, length)?; write!(f, "(slice {start} {length} ")?;
} else { } else {
write!(f, "(slice {} _ ", start)?; write!(f, "(slice {start} _ ")?;
} }
inner.fmt_sse(f)?; inner.fmt_sse(f)?;
write!(f, ")") write!(f, ")")
@ -783,7 +783,7 @@ impl fmt::Display for GraphPattern {
match self { match self {
Self::Bgp { patterns } => { Self::Bgp { patterns } => {
for pattern in patterns { for pattern in patterns {
write!(f, "{} .", pattern)? write!(f, "{pattern} .")?
} }
Ok(()) Ok(())
} }
@ -791,7 +791,7 @@ impl fmt::Display for GraphPattern {
subject, subject,
path, path,
object, object,
} => write!(f, "{} {} {} .", subject, path, object), } => write!(f, "{subject} {path} {object} ."),
Self::Join { left, right } => { Self::Join { left, right } => {
if matches!( if matches!(
right.as_ref(), right.as_ref(),
@ -801,9 +801,9 @@ impl fmt::Display for GraphPattern {
| Self::Filter { .. } | Self::Filter { .. }
) { ) {
// The second block might be considered as a modification of the first one. // The second block might be considered as a modification of the first one.
write!(f, "{} {{ {} }}", left, right) write!(f, "{left} {{ {right} }}")
} else { } else {
write!(f, "{} {}", left, right) write!(f, "{left} {right}")
} }
} }
Self::LeftJoin { Self::LeftJoin {
@ -812,33 +812,33 @@ impl fmt::Display for GraphPattern {
expression, expression,
} => { } => {
if let Some(expr) = expression { if let Some(expr) = expression {
write!(f, "{} OPTIONAL {{ {} FILTER({}) }}", left, right, expr) write!(f, "{left} OPTIONAL {{ {right} FILTER({expr}) }}")
} else { } else {
write!(f, "{} OPTIONAL {{ {} }}", left, right) write!(f, "{left} OPTIONAL {{ {right} }}")
} }
} }
Self::Filter { expr, inner } => { 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 } => { Self::Graph { name, inner } => {
write!(f, "GRAPH {} {{ {} }}", name, inner) write!(f, "GRAPH {name} {{ {inner} }}")
} }
Self::Extend { Self::Extend {
inner, inner,
variable, variable,
expression, expression,
} => write!(f, "{} BIND({} AS {})", inner, expression, variable), } => write!(f, "{inner} BIND({expression} AS {variable})"),
Self::Minus { left, right } => write!(f, "{} MINUS {{ {} }}", left, right), Self::Minus { left, right } => write!(f, "{left} MINUS {{ {right} }}"),
Self::Service { Self::Service {
name, name,
inner, inner,
silent, silent,
} => { } => {
if *silent { if *silent {
write!(f, "SERVICE SILENT {} {{ {} }}", name, inner) write!(f, "SERVICE SILENT {name} {{ {inner} }}")
} else { } else {
write!(f, "SERVICE {} {{ {} }}", name, inner) write!(f, "SERVICE {name} {{ {inner} }}")
} }
} }
Self::Values { Self::Values {
@ -847,14 +847,14 @@ impl fmt::Display for GraphPattern {
} => { } => {
write!(f, "VALUES ( ")?; write!(f, "VALUES ( ")?;
for var in variables { for var in variables {
write!(f, "{} ", var)?; write!(f, "{var} ")?;
} }
write!(f, ") {{ ")?; write!(f, ") {{ ")?;
for row in bindings { for row in bindings {
write!(f, "( ")?; write!(f, "( ")?;
for val in row { for val in row {
match val { match val {
Some(val) => write!(f, "{} ", val), Some(val) => write!(f, "{val} "),
None => write!(f, "UNDEF "), None => write!(f, "UNDEF "),
}?; }?;
} }
@ -869,16 +869,16 @@ impl fmt::Display for GraphPattern {
} => { } => {
write!(f, "{{SELECT")?; write!(f, "{{SELECT")?;
for (a, v) in aggregates { for (a, v) in aggregates {
write!(f, " ({} AS {})", v, a)?; write!(f, " ({v} AS {a})")?;
} }
for b in variables { for b in variables {
write!(f, " {}", b)?; write!(f, " {b}")?;
} }
write!(f, " WHERE {{ {} }}", inner)?; write!(f, " WHERE {{ {inner} }}")?;
if !variables.is_empty() { if !variables.is_empty() {
write!(f, " GROUP BY")?; write!(f, " GROUP BY")?;
for v in variables { for v in variables {
write!(f, " {}", v)?; write!(f, " {v}")?;
} }
} }
write!(f, "}}") write!(f, "}}")
@ -1062,24 +1062,24 @@ impl<'a> fmt::Display for SparqlGraphRootPattern<'a> {
write!(f, " *")?; write!(f, " *")?;
} else { } else {
for v in project { for v in project {
write!(f, " {}", v)?; write!(f, " {v}")?;
} }
} }
if let Some(dataset) = self.dataset { 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 { if let Some(order) = order {
write!(f, " ORDER BY")?; write!(f, " ORDER BY")?;
for c in order { for c in order {
write!(f, " {}", c)?; write!(f, " {c}")?;
} }
} }
if start > 0 { if start > 0 {
write!(f, " OFFSET {}", start)?; write!(f, " OFFSET {start}")?;
} }
if let Some(length) = length { if let Some(length) = length {
write!(f, " LIMIT {}", length)?; write!(f, " LIMIT {length}")?;
} }
return Ok(()); return Ok(());
} }
@ -1210,7 +1210,7 @@ impl AggregateExpression {
expr, expr,
distinct, distinct,
} => { } => {
write!(f, "({}", name)?; write!(f, "({name}")?;
if *distinct { if *distinct {
write!(f, " distinct")?; write!(f, " distinct")?;
} }
@ -1228,49 +1228,49 @@ impl fmt::Display for AggregateExpression {
Self::Count { expr, distinct } => { Self::Count { expr, distinct } => {
if *distinct { if *distinct {
if let Some(expr) = expr { if let Some(expr) = expr {
write!(f, "COUNT(DISTINCT {})", expr) write!(f, "COUNT(DISTINCT {expr})")
} else { } else {
write!(f, "COUNT(DISTINCT *)") write!(f, "COUNT(DISTINCT *)")
} }
} else if let Some(expr) = expr { } else if let Some(expr) = expr {
write!(f, "COUNT({})", expr) write!(f, "COUNT({expr})")
} else { } else {
write!(f, "COUNT(*)") write!(f, "COUNT(*)")
} }
} }
Self::Sum { expr, distinct } => { Self::Sum { expr, distinct } => {
if *distinct { if *distinct {
write!(f, "SUM(DISTINCT {})", expr) write!(f, "SUM(DISTINCT {expr})")
} else { } else {
write!(f, "SUM({})", expr) write!(f, "SUM({expr})")
} }
} }
Self::Min { expr, distinct } => { Self::Min { expr, distinct } => {
if *distinct { if *distinct {
write!(f, "MIN(DISTINCT {})", expr) write!(f, "MIN(DISTINCT {expr})")
} else { } else {
write!(f, "MIN({})", expr) write!(f, "MIN({expr})")
} }
} }
Self::Max { expr, distinct } => { Self::Max { expr, distinct } => {
if *distinct { if *distinct {
write!(f, "MAX(DISTINCT {})", expr) write!(f, "MAX(DISTINCT {expr})")
} else { } else {
write!(f, "MAX({})", expr) write!(f, "MAX({expr})")
} }
} }
Self::Avg { expr, distinct } => { Self::Avg { expr, distinct } => {
if *distinct { if *distinct {
write!(f, "AVG(DISTINCT {})", expr) write!(f, "AVG(DISTINCT {expr})")
} else { } else {
write!(f, "AVG({})", expr) write!(f, "AVG({expr})")
} }
} }
Self::Sample { expr, distinct } => { Self::Sample { expr, distinct } => {
if *distinct { if *distinct {
write!(f, "SAMPLE(DISTINCT {})", expr) write!(f, "SAMPLE(DISTINCT {expr})")
} else { } else {
write!(f, "SAMPLE({})", expr) write!(f, "SAMPLE({expr})")
} }
} }
Self::GroupConcat { Self::GroupConcat {
@ -1287,7 +1287,7 @@ impl fmt::Display for AggregateExpression {
LiteralRef::new_simple_literal(separator) LiteralRef::new_simple_literal(separator)
) )
} else { } else {
write!(f, "GROUP_CONCAT(DISTINCT {})", expr) write!(f, "GROUP_CONCAT(DISTINCT {expr})")
} }
} else if let Some(separator) = separator { } else if let Some(separator) = separator {
write!( write!(
@ -1297,7 +1297,7 @@ impl fmt::Display for AggregateExpression {
LiteralRef::new_simple_literal(separator) LiteralRef::new_simple_literal(separator)
) )
} else { } else {
write!(f, "GROUP_CONCAT({})", expr) write!(f, "GROUP_CONCAT({expr})")
} }
} }
Self::Custom { Self::Custom {
@ -1306,9 +1306,9 @@ impl fmt::Display for AggregateExpression {
distinct, distinct,
} => { } => {
if *distinct { if *distinct {
write!(f, "{}(DISTINCT {})", name, expr) write!(f, "{name}(DISTINCT {expr})")
} else { } else {
write!(f, "{}({})", name, expr) write!(f, "{name}({expr})")
} }
} }
} }
@ -1345,8 +1345,8 @@ impl OrderExpression {
impl fmt::Display for OrderExpression { impl fmt::Display for OrderExpression {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Self::Asc(e) => write!(f, "ASC({})", e), Self::Asc(e) => write!(f, "ASC({e})"),
Self::Desc(e) => write!(f, "DESC({})", e), Self::Desc(e) => write!(f, "DESC({e})"),
} }
} }
} }
@ -1366,14 +1366,14 @@ impl QueryDataset {
if i > 0 { if i > 0 {
write!(f, " ")?; write!(f, " ")?;
} }
write!(f, "{}", graph_name)?; write!(f, "{graph_name}")?;
} }
if let Some(named) = &self.named { if let Some(named) = &self.named {
for (i, graph_name) in named.iter().enumerate() { for (i, graph_name) in named.iter().enumerate() {
if !self.default.is_empty() || i > 0 { if !self.default.is_empty() || i > 0 {
write!(f, " ")?; write!(f, " ")?;
} }
write!(f, "(named {})", graph_name)?; write!(f, "(named {graph_name})")?;
} }
} }
write!(f, ")") write!(f, ")")
@ -1383,11 +1383,11 @@ impl QueryDataset {
impl fmt::Display for QueryDataset { impl fmt::Display for QueryDataset {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
for g in &self.default { for g in &self.default {
write!(f, " FROM {}", g)?; write!(f, " FROM {g}")?;
} }
if let Some(named) = &self.named { if let Some(named) = &self.named {
for g in named { for g in named {
write!(f, " FROM NAMED {}", g)?; write!(f, " FROM NAMED {g}")?;
} }
} }
Ok(()) Ok(())
@ -1409,7 +1409,7 @@ impl GraphTarget {
/// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html). /// 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 { pub(crate) fn fmt_sse(&self, f: &mut impl fmt::Write) -> fmt::Result {
match self { match self {
Self::NamedNode(node) => write!(f, "{}", node), Self::NamedNode(node) => write!(f, "{node}"),
Self::DefaultGraph => write!(f, "default"), Self::DefaultGraph => write!(f, "default"),
Self::NamedGraphs => write!(f, "named"), Self::NamedGraphs => write!(f, "named"),
Self::AllGraphs => write!(f, "all"), Self::AllGraphs => write!(f, "all"),
@ -1420,7 +1420,7 @@ impl GraphTarget {
impl fmt::Display for GraphTarget { impl fmt::Display for GraphTarget {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Self::NamedNode(node) => write!(f, "GRAPH {}", node), Self::NamedNode(node) => write!(f, "GRAPH {node}"),
Self::DefaultGraph => write!(f, "DEFAULT"), Self::DefaultGraph => write!(f, "DEFAULT"),
Self::NamedGraphs => write!(f, "NAMED"), Self::NamedGraphs => write!(f, "NAMED"),
Self::AllGraphs => write!(f, "ALL"), Self::AllGraphs => write!(f, "ALL"),
@ -1445,7 +1445,7 @@ impl From<GraphName> for GraphTarget {
#[inline] #[inline]
fn fmt_sse_unary_expression(f: &mut impl fmt::Write, name: &str, e: &Expression) -> fmt::Result { 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)?; e.fmt_sse(f)?;
write!(f, ")") write!(f, ")")
} }
@ -1457,7 +1457,7 @@ fn fmt_sse_binary_expression(
a: &Expression, a: &Expression,
b: &Expression, b: &Expression,
) -> fmt::Result { ) -> fmt::Result {
write!(f, "({} ", name)?; write!(f, "({name} ")?;
a.fmt_sse(f)?; a.fmt_sse(f)?;
write!(f, " ")?; write!(f, " ")?;
b.fmt_sse(f)?; b.fmt_sse(f)?;

@ -82,7 +82,7 @@ impl fmt::Display for ParseError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match &self.inner { match &self.inner {
ParseErrorKind::InvalidBaseIri(e) => { 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), ParseErrorKind::Parser(e) => e.fmt(f),
} }

@ -81,7 +81,7 @@ impl Query {
base_iri, base_iri,
} => { } => {
if let Some(base_iri) = base_iri { if let Some(base_iri) = base_iri {
write!(f, "(base <{}> ", base_iri)?; write!(f, "(base <{base_iri}> ")?;
} }
if let Some(dataset) = dataset { if let Some(dataset) = dataset {
write!(f, "(dataset ")?; write!(f, "(dataset ")?;
@ -104,7 +104,7 @@ impl Query {
base_iri, base_iri,
} => { } => {
if let Some(base_iri) = base_iri { if let Some(base_iri) = base_iri {
write!(f, "(base <{}> ", base_iri)?; write!(f, "(base <{base_iri}> ")?;
} }
write!(f, "(construct (")?; write!(f, "(construct (")?;
for (i, t) in template.iter().enumerate() { for (i, t) in template.iter().enumerate() {
@ -135,7 +135,7 @@ impl Query {
base_iri, base_iri,
} => { } => {
if let Some(base_iri) = base_iri { if let Some(base_iri) = base_iri {
write!(f, "(base <{}> ", base_iri)?; write!(f, "(base <{base_iri}> ")?;
} }
write!(f, "(describe ")?; write!(f, "(describe ")?;
if let Some(dataset) = dataset { if let Some(dataset) = dataset {
@ -159,7 +159,7 @@ impl Query {
base_iri, base_iri,
} => { } => {
if let Some(base_iri) = base_iri { if let Some(base_iri) = base_iri {
write!(f, "(base <{}> ", base_iri)?; write!(f, "(base <{base_iri}> ")?;
} }
write!(f, "(ask ")?; write!(f, "(ask ")?;
if let Some(dataset) = dataset { if let Some(dataset) = dataset {
@ -190,7 +190,7 @@ impl fmt::Display for Query {
base_iri, base_iri,
} => { } => {
if let Some(base_iri) = base_iri { if let Some(base_iri) = base_iri {
writeln!(f, "BASE <{}>", base_iri)?; writeln!(f, "BASE <{base_iri}>")?;
} }
write!( write!(
f, f,
@ -208,11 +208,11 @@ impl fmt::Display for Query {
base_iri, base_iri,
} => { } => {
if let Some(base_iri) = base_iri { if let Some(base_iri) = base_iri {
writeln!(f, "BASE <{}>", base_iri)?; writeln!(f, "BASE <{base_iri}>")?;
} }
write!(f, "CONSTRUCT {{ ")?; write!(f, "CONSTRUCT {{ ")?;
for triple in template.iter() { for triple in template.iter() {
write!(f, "{} . ", triple)?; write!(f, "{triple} . ")?;
} }
write!(f, "}}")?; write!(f, "}}")?;
if let Some(dataset) = dataset { if let Some(dataset) = dataset {
@ -254,7 +254,7 @@ impl fmt::Display for Query {
base_iri, base_iri,
} => { } => {
if let Some(base_iri) = base_iri { if let Some(base_iri) = base_iri {
writeln!(f, "BASE <{}>", base_iri)?; writeln!(f, "BASE <{base_iri}>")?;
} }
write!(f, "ASK")?; write!(f, "ASK")?;
if let Some(dataset) = dataset { if let Some(dataset) = dataset {

@ -193,7 +193,7 @@ impl GraphName {
/// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html). /// 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 { pub(crate) fn fmt_sse(&self, f: &mut impl Write) -> fmt::Result {
match self { match self {
Self::NamedNode(node) => write!(f, "{}", node), Self::NamedNode(node) => write!(f, "{node}"),
Self::DefaultGraph => write!(f, "default"), 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). /// 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 { pub(crate) fn fmt_sse(&self, f: &mut impl Write) -> fmt::Result {
match self { match self {
Self::NamedNode(node) => write!(f, "{}", node), Self::NamedNode(node) => write!(f, "{node}"),
Self::Variable(var) => write!(f, "{}", var), 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). /// 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 { pub(crate) fn fmt_sse(&self, f: &mut impl Write) -> fmt::Result {
match self { match self {
Self::NamedNode(term) => write!(f, "{}", term), Self::NamedNode(term) => write!(f, "{term}"),
Self::BlankNode(term) => write!(f, "{}", term), Self::BlankNode(term) => write!(f, "{term}"),
Self::Literal(term) => write!(f, "{}", term), Self::Literal(term) => write!(f, "{term}"),
#[cfg(feature = "rdf-star")] #[cfg(feature = "rdf-star")]
Self::Triple(triple) => triple.fmt_sse(f), 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::BlankNode(term) => term.fmt(f),
Self::Literal(term) => term.fmt(f), Self::Literal(term) => term.fmt(f),
#[cfg(feature = "rdf-star")] #[cfg(feature = "rdf-star")]
Self::Triple(triple) => write!(f, "<<{}>>", triple), Self::Triple(triple) => write!(f, "<<{triple}>>"),
Self::Variable(var) => var.fmt(f), 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). /// 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 { pub(crate) fn fmt_sse(&self, f: &mut impl Write) -> fmt::Result {
match self { match self {
Self::NamedNode(term) => write!(f, "{}", term), Self::NamedNode(term) => write!(f, "{term}"),
Self::Literal(term) => write!(f, "{}", term), Self::Literal(term) => write!(f, "{term}"),
Self::Variable(var) => write!(f, "{}", var), Self::Variable(var) => write!(f, "{var}"),
Self::Triple(triple) => triple.fmt_sse(f), Self::Triple(triple) => triple.fmt_sse(f),
} }
} }
@ -599,7 +599,7 @@ impl fmt::Display for GroundTermPattern {
Self::NamedNode(term) => term.fmt(f), Self::NamedNode(term) => term.fmt(f),
Self::Literal(term) => term.fmt(f), Self::Literal(term) => term.fmt(f),
Self::Variable(var) => var.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). /// 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 { pub(crate) fn fmt_sse(&self, f: &mut impl Write) -> fmt::Result {
match self { match self {
Self::NamedNode(node) => write!(f, "{}", node), Self::NamedNode(node) => write!(f, "{node}"),
Self::DefaultGraph => write!(f, "default"), Self::DefaultGraph => write!(f, "default"),
Self::Variable(var) => write!(f, "{}", var), Self::Variable(var) => write!(f, "{var}"),
} }
} }
} }

@ -41,7 +41,7 @@ impl Update {
/// Formats using the [SPARQL S-Expression syntax](https://jena.apache.org/documentation/notes/sse.html). /// 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 { fn fmt_sse(&self, f: &mut impl fmt::Write) -> fmt::Result {
if let Some(base_iri) = &self.base_iri { if let Some(base_iri) = &self.base_iri {
write!(f, "(base <{}> ", base_iri)?; write!(f, "(base <{base_iri}> ")?;
} }
write!(f, "(update")?; write!(f, "(update")?;
for op in &self.operations { for op in &self.operations {
@ -59,10 +59,10 @@ impl Update {
impl fmt::Display for Update { impl fmt::Display for Update {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if let Some(base_iri) = &self.base_iri { if let Some(base_iri) = &self.base_iri {
writeln!(f, "BASE <{}>", base_iri)?; writeln!(f, "BASE <{base_iri}>")?;
} }
for update in &self.operations { for update in &self.operations {
writeln!(f, "{} ;", update)?; writeln!(f, "{update} ;")?;
} }
Ok(()) Ok(())
} }
@ -191,7 +191,7 @@ impl GraphUpdateOperation {
if *silent { if *silent {
write!(f, "silent ")?; write!(f, "silent ")?;
} }
write!(f, "{} ", source)?; write!(f, "{source} ")?;
destination.fmt_sse(f)?; destination.fmt_sse(f)?;
write!(f, ")") write!(f, ")")
} }
@ -208,7 +208,7 @@ impl GraphUpdateOperation {
if *silent { if *silent {
write!(f, "silent ")?; write!(f, "silent ")?;
} }
write!(f, "{})", graph) write!(f, "{graph})")
} }
GraphUpdateOperation::Drop { silent, graph } => { GraphUpdateOperation::Drop { silent, graph } => {
write!(f, "(drop ")?; write!(f, "(drop ")?;
@ -244,24 +244,24 @@ impl fmt::Display for GraphUpdateOperation {
if !delete.is_empty() { if !delete.is_empty() {
writeln!(f, "DELETE {{")?; writeln!(f, "DELETE {{")?;
for quad in delete { for quad in delete {
writeln!(f, "\t{} .", quad)?; writeln!(f, "\t{quad} .")?;
} }
writeln!(f, "}}")?; writeln!(f, "}}")?;
} }
if !insert.is_empty() { if !insert.is_empty() {
writeln!(f, "INSERT {{")?; writeln!(f, "INSERT {{")?;
for quad in insert { for quad in insert {
writeln!(f, "\t{} .", quad)?; writeln!(f, "\t{quad} .")?;
} }
writeln!(f, "}}")?; writeln!(f, "}}")?;
} }
if let Some(using) = using { if let Some(using) = using {
for g in &using.default { for g in &using.default {
writeln!(f, "USING {}", g)?; writeln!(f, "USING {g}")?;
} }
if let Some(named) = &using.named { if let Some(named) = &using.named {
for g in 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 { if *silent {
write!(f, "SILENT ")?; write!(f, "SILENT ")?;
} }
write!(f, "{}", source)?; write!(f, "{source}")?;
if destination != &GraphName::DefaultGraph { if destination != &GraphName::DefaultGraph {
write!(f, " INTO GRAPH {}", destination)?; write!(f, " INTO GRAPH {destination}")?;
} }
Ok(()) Ok(())
} }
@ -294,21 +294,21 @@ impl fmt::Display for GraphUpdateOperation {
if *silent { if *silent {
write!(f, "SILENT ")?; write!(f, "SILENT ")?;
} }
write!(f, "{}", graph) write!(f, "{graph}")
} }
GraphUpdateOperation::Create { silent, graph } => { GraphUpdateOperation::Create { silent, graph } => {
write!(f, "CREATE ")?; write!(f, "CREATE ")?;
if *silent { if *silent {
write!(f, "SILENT ")?; write!(f, "SILENT ")?;
} }
write!(f, "GRAPH {}", graph) write!(f, "GRAPH {graph}")
} }
GraphUpdateOperation::Drop { silent, graph } => { GraphUpdateOperation::Drop { silent, graph } => {
write!(f, "DROP ")?; write!(f, "DROP ")?;
if *silent { if *silent {
write!(f, "SILENT ")?; write!(f, "SILENT ")?;
} }
write!(f, "{}", graph) write!(f, "{graph}")
} }
} }
} }

@ -47,7 +47,7 @@ enum QueryVariant {
impl fmt::Display for Query { impl fmt::Display for Query {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match &self.variant { match &self.variant {
QueryVariant::Select(s) => write!(f, "{}", s), QueryVariant::Select(s) => write!(f, "{s}"),
}?; }?;
write!(f, "{}", self.values_clause) write!(f, "{}", self.values_clause)
} }
@ -138,8 +138,8 @@ impl fmt::Display for SelectClause {
SelectValues::Projection { start, others } => { SelectValues::Projection { start, others } => {
for e in once(start).chain(others) { for e in once(start).chain(others) {
match e { match e {
SelectProjection::Variable(v) => write!(f, " {}", v), SelectProjection::Variable(v) => write!(f, " {v}"),
SelectProjection::Projection(e, v) => write!(f, " ({} AS {})", e, v), SelectProjection::Projection(e, v) => write!(f, " ({e} AS {v})"),
}?; }?;
} }
Ok(()) Ok(())
@ -176,16 +176,16 @@ struct SolutionModifier {
impl fmt::Display for SolutionModifier { impl fmt::Display for SolutionModifier {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if let Some(group) = &self.group { if let Some(group) = &self.group {
write!(f, " {}", group)?; write!(f, " {group}")?;
} }
if let Some(having) = &self.having { if let Some(having) = &self.having {
write!(f, " {}", having)?; write!(f, " {having}")?;
} }
if let Some(order) = &self.order { if let Some(order) = &self.order {
write!(f, " {}", order)?; write!(f, " {order}")?;
} }
if let Some(limit_offset) = &self.limit_offset { if let Some(limit_offset) = &self.limit_offset {
write!(f, " {}", limit_offset)?; write!(f, " {limit_offset}")?;
} }
Ok(()) Ok(())
} }
@ -202,7 +202,7 @@ impl fmt::Display for GroupClause {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "GROUP BY {}", self.start)?; write!(f, "GROUP BY {}", self.start)?;
for o in &self.others { for o in &self.others {
write!(f, " {}", o)?; write!(f, " {o}")?;
} }
Ok(()) Ok(())
} }
@ -220,16 +220,16 @@ enum GroupCondition {
impl fmt::Display for GroupCondition { impl fmt::Display for GroupCondition {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Self::BuiltInCall(c) => write!(f, "{}", c), Self::BuiltInCall(c) => write!(f, "{c}"),
//Self::FunctionCall(c) => write!(f, "{}", c), //Self::FunctionCall(c) => write!(f, "{}", c),
Self::Projection(e, v) => { Self::Projection(e, v) => {
if let Some(v) = v { if let Some(v) = v {
write!(f, "({} AS {})", e, v) write!(f, "({e} AS {v})")
} else { } 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 { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "HAVING {}", self.start)?; write!(f, "HAVING {}", self.start)?;
for o in &self.others { for o in &self.others {
write!(f, " {}", o)?; write!(f, " {o}")?;
} }
Ok(()) Ok(())
} }
@ -265,7 +265,7 @@ impl fmt::Display for OrderClause {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "ORDER BY {}", self.start)?; write!(f, "ORDER BY {}", self.start)?;
for other in &self.others { for other in &self.others {
write!(f, " {}", other)?; write!(f, " {other}")?;
} }
Ok(()) Ok(())
} }
@ -287,13 +287,13 @@ impl fmt::Display for OrderCondition {
match self { match self {
Self::BrackettedExpression { is_asc, inner } => { Self::BrackettedExpression { is_asc, inner } => {
if *is_asc { if *is_asc {
write!(f, "ASC{}", inner) write!(f, "ASC{inner}")
} else { } else {
write!(f, "DESC{}", inner) write!(f, "DESC{inner}")
} }
} }
Self::Constraint(c) => write!(f, "{}", c), Self::Constraint(c) => write!(f, "{c}"),
Self::Var(v) => write!(f, "{}", v), Self::Var(v) => write!(f, "{v}"),
} }
} }
} }
@ -308,10 +308,10 @@ enum LimitOffsetClauses {
impl fmt::Display for LimitOffsetClauses { impl fmt::Display for LimitOffsetClauses {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Self::LimitOffset(l, Some(o)) => write!(f, "{} {}", l, o), Self::LimitOffset(l, Some(o)) => write!(f, "{l} {o}"),
Self::LimitOffset(l, None) => write!(f, "{}", l), Self::LimitOffset(l, None) => write!(f, "{l}"),
Self::OffsetLimit(o, Some(l)) => write!(f, "{} {}", o, l), Self::OffsetLimit(o, Some(l)) => write!(f, "{o} {l}"),
Self::OffsetLimit(o, None) => write!(f, "{}", o), Self::OffsetLimit(o, None) => write!(f, "{o}"),
} }
} }
} }
@ -349,7 +349,7 @@ struct ValuesClause {
impl fmt::Display for ValuesClause { impl fmt::Display for ValuesClause {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if let Some(value) = &self.value { if let Some(value) = &self.value {
write!(f, " VALUES {}", value) write!(f, " VALUES {value}")
} else { } else {
Ok(()) Ok(())
} }
@ -367,8 +367,8 @@ impl fmt::Display for GroupGraphPattern {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, " {{ ")?; write!(f, " {{ ")?;
match self { match self {
Self::GroupGraphPatternSub(p) => write!(f, "{}", p), Self::GroupGraphPatternSub(p) => write!(f, "{p}"),
Self::SubSelect(s) => write!(f, "{}", s), Self::SubSelect(s) => write!(f, "{s}"),
}?; }?;
write!(f, " }} ") write!(f, " }} ")
} }
@ -391,7 +391,7 @@ struct GroupGraphPatternSubOtherBlock {
impl fmt::Display for GroupGraphPatternSub { impl fmt::Display for GroupGraphPatternSub {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if let Some(start) = &self.start { if let Some(start) = &self.start {
write!(f, "{}", start)?; write!(f, "{start}")?;
} }
for other in &self.others { for other in &self.others {
write!(f, "{}", other.start)?; write!(f, "{}", other.start)?;
@ -399,7 +399,7 @@ impl fmt::Display for GroupGraphPatternSub {
write!(f, " . ")?; write!(f, " . ")?;
} }
if let Some(end) = &other.end { if let Some(end) = &other.end {
write!(f, "{}", end)?; write!(f, "{end}")?;
} }
} }
Ok(()) Ok(())
@ -419,7 +419,7 @@ impl fmt::Display for TriplesBlock {
if let Some(end) = &self.end { if let Some(end) = &self.end {
write!(f, " . ")?; write!(f, " . ")?;
if let Some(end) = end { if let Some(end) = end {
write!(f, "{}", end)?; write!(f, "{end}")?;
} }
} }
Ok(()) Ok(())
@ -441,13 +441,13 @@ enum GraphPatternNotTriples {
impl fmt::Display for GraphPatternNotTriples { impl fmt::Display for GraphPatternNotTriples {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Self::GroupOrUnion(p) => write!(f, "{}", p), Self::GroupOrUnion(p) => write!(f, "{p}"),
Self::Optional(p) => write!(f, "{}", p), Self::Optional(p) => write!(f, "{p}"),
Self::Minus(p) => write!(f, "{}", p), Self::Minus(p) => write!(f, "{p}"),
Self::Graph(p) => write!(f, "{}", p), Self::Graph(p) => write!(f, "{p}"),
Self::Filter(p) => write!(f, "{}", p), Self::Filter(p) => write!(f, "{p}"),
Self::Bind(p) => write!(f, "{}", p), Self::Bind(p) => write!(f, "{p}"),
Self::InlineData(p) => write!(f, "{}", p), Self::InlineData(p) => write!(f, "{p}"),
} }
} }
} }
@ -512,8 +512,8 @@ enum DataBlock {
impl fmt::Display for DataBlock { impl fmt::Display for DataBlock {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Self::OneVar(e) => write!(f, "{}", e), Self::OneVar(e) => write!(f, "{e}"),
Self::Full(c) => write!(f, "{}", c), Self::Full(c) => write!(f, "{c}"),
} }
} }
} }
@ -529,7 +529,7 @@ impl fmt::Display for InlineDataOneVar {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{} {{", self.var)?; write!(f, "{} {{", self.var)?;
for v in &self.values { for v in &self.values {
write!(f, " {}", v)?; write!(f, " {v}")?;
} }
write!(f, " }}") write!(f, " }}")
} }
@ -569,13 +569,13 @@ impl fmt::Display for InlineDataFull {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "( ")?; write!(f, "( ")?;
for v in &self.vars { for v in &self.vars {
write!(f, " {}", v)?; write!(f, " {v}")?;
} }
write!(f, " ) {{")?; write!(f, " ) {{")?;
for vs in &self.values { for vs in &self.values {
write!(f, " (")?; write!(f, " (")?;
for v in vs { for v in vs {
write!(f, " {}", v)?; write!(f, " {v}")?;
} }
write!(f, " )")?; write!(f, " )")?;
} }
@ -594,8 +594,8 @@ enum DataBlockValue {
impl fmt::Display for DataBlockValue { impl fmt::Display for DataBlockValue {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Self::Iri(i) => write!(f, "{}", i), Self::Iri(i) => write!(f, "{i}"),
Self::Literal(l) => write!(f, "{}", l), Self::Literal(l) => write!(f, "{l}"),
Self::Undef => write!(f, "UNDEF"), Self::Undef => write!(f, "UNDEF"),
} }
} }
@ -624,7 +624,7 @@ impl fmt::Display for GroupOrUnionGraphPattern {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.start)?; write!(f, "{}", self.start)?;
for other in &self.others { for other in &self.others {
write!(f, " UNION {}", other)?; write!(f, " UNION {other}")?;
} }
Ok(()) Ok(())
} }
@ -653,8 +653,8 @@ enum Constraint {
impl fmt::Display for Constraint { impl fmt::Display for Constraint {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Self::BrackettedExpression(e) => write!(f, "{}", e), Self::BrackettedExpression(e) => write!(f, "{e}"),
Self::BuiltInCall(c) => write!(f, "{}", c), Self::BuiltInCall(c) => write!(f, "{c}"),
//Self::FunctionCall(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 { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "(")?; write!(f, "(")?;
if let Self::NotNil { start, others } = self { if let Self::NotNil { start, others } = self {
write!(f, "{}", start)?; write!(f, "{start}")?;
for e in others { for e in others {
write!(f, ", {}", e)?; write!(f, ", {e}")?;
} }
} }
write!(f, ")") write!(f, ")")
@ -710,7 +710,7 @@ impl fmt::Display for ExpressionList {
if i > 0 { if i > 0 {
write!(f, ", ")?; write!(f, ", ")?;
} }
write!(f, "{}", e)?; write!(f, "{e}")?;
} }
write!(f, ")") write!(f, ")")
} }
@ -753,7 +753,7 @@ enum Verb {
impl fmt::Display for Verb { impl fmt::Display for Verb {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Self::VarOrIri(iri) => write!(f, "{}", iri), Self::VarOrIri(iri) => write!(f, "{iri}"),
Self::A => write!(f, " a "), Self::A => write!(f, " a "),
} }
} }
@ -771,7 +771,7 @@ impl fmt::Display for ObjectList {
write!(f, "{}", self.start)?; write!(f, "{}", self.start)?;
for other in &self.others { for other in &self.others {
write!(f, " , ")?; write!(f, " , ")?;
write!(f, "{}", other)?; write!(f, "{other}")?;
} }
Ok(()) Ok(())
} }
@ -800,13 +800,13 @@ impl fmt::Display for TriplesSameSubjectPath {
subject, subject,
predicate_object, predicate_object,
} => { } => {
write!(f, "{}{}", subject, predicate_object) write!(f, "{subject}{predicate_object}")
} }
Self::Other { Self::Other {
subject, subject,
predicate_object, predicate_object,
} => { } => {
write!(f, "{} {}", subject, predicate_object) write!(f, "{subject} {predicate_object}")
} }
} }
} }
@ -821,7 +821,7 @@ struct PropertyListPath {
impl fmt::Display for PropertyListPath { impl fmt::Display for PropertyListPath {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if let Some(p) = &self.inner { if let Some(p) = &self.inner {
write!(f, "{}", p) write!(f, "{p}")
} else { } else {
Ok(()) Ok(())
} }
@ -851,16 +851,16 @@ struct PropertyListPathElement {
impl fmt::Display for PropertyListPathNotEmpty { impl fmt::Display for PropertyListPathNotEmpty {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match &self.start_predicate { match &self.start_predicate {
PropertyListPathNotEmptyVerb::VerbPath(p) => write!(f, "{}", p), PropertyListPathNotEmptyVerb::VerbPath(p) => write!(f, "{p}"),
PropertyListPathNotEmptyVerb::VerbSimple(s) => write!(f, "{}", s), PropertyListPathNotEmptyVerb::VerbSimple(s) => write!(f, "{s}"),
}?; }?;
write!(f, "{}", self.start_object)?; write!(f, "{}", self.start_object)?;
for other in &self.others { for other in &self.others {
write!(f, " ; ")?; write!(f, " ; ")?;
if let Some(e) = other { if let Some(e) = other {
match &e.predicate { match &e.predicate {
PropertyListPathNotEmptyVerb::VerbPath(p) => write!(f, "{}", p), PropertyListPathNotEmptyVerb::VerbPath(p) => write!(f, "{p}"),
PropertyListPathNotEmptyVerb::VerbSimple(s) => write!(f, "{}", s), PropertyListPathNotEmptyVerb::VerbSimple(s) => write!(f, "{s}"),
}?; }?;
write!(f, "{}", e.object)?; write!(f, "{}", e.object)?;
} }
@ -886,7 +886,7 @@ impl fmt::Display for ObjectListPath {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.start)?; write!(f, "{}", self.start)?;
for other in &self.others { for other in &self.others {
write!(f, " , {}", other)?; write!(f, " , {other}")?;
} }
Ok(()) Ok(())
} }
@ -909,7 +909,7 @@ impl fmt::Display for PathAlternative {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.start)?; write!(f, "{}", self.start)?;
for other in &self.others { for other in &self.others {
write!(f, " | {}", other)?; write!(f, " | {other}")?;
} }
Ok(()) Ok(())
} }
@ -926,7 +926,7 @@ impl fmt::Display for PathSequence {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.start)?; write!(f, "{}", self.start)?;
for other in &self.others { for other in &self.others {
write!(f, " / {}", other)?; write!(f, " / {other}")?;
} }
Ok(()) Ok(())
} }
@ -943,7 +943,7 @@ impl fmt::Display for PathElt {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.path)?; write!(f, "{}", self.path)?;
if let Some(mode) = &self.mode { if let Some(mode) = &self.mode {
write!(f, "{}", mode)?; write!(f, "{mode}")?;
} }
Ok(()) Ok(())
} }
@ -959,8 +959,8 @@ enum PathEltOrInverse {
impl fmt::Display for PathEltOrInverse { impl fmt::Display for PathEltOrInverse {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Self::PathElt(e) => write!(f, "{}", e), Self::PathElt(e) => write!(f, "{e}"),
Self::Inverse(e) => write!(f, " ^{}", e), Self::Inverse(e) => write!(f, " ^{e}"),
} }
} }
} }
@ -995,10 +995,10 @@ enum PathPrimary {
impl fmt::Display for PathPrimary { impl fmt::Display for PathPrimary {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Self::Iri(iri) => write!(f, "{}", iri), Self::Iri(iri) => write!(f, "{iri}"),
Self::A => write!(f, " a "), Self::A => write!(f, " a "),
Self::Negated(n) => write!(f, "!{}", n), Self::Negated(n) => write!(f, "!{n}"),
Self::Child(c) => write!(f, "({})", c), Self::Child(c) => write!(f, "({c})"),
} }
} }
} }
@ -1016,11 +1016,11 @@ enum PathNegatedPropertySet {
impl fmt::Display for PathNegatedPropertySet { impl fmt::Display for PathNegatedPropertySet {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Self::Single(p) => write!(f, "{}", p), Self::Single(p) => write!(f, "{p}"),
Self::Multiple { start, others } => { Self::Multiple { start, others } => {
write!(f, " ( {}", start)?; write!(f, " ( {start}")?;
for other in others { for other in others {
write!(f, " | {}", other)?; write!(f, " | {other}")?;
} }
write!(f, " ) ") write!(f, " ) ")
} }
@ -1040,9 +1040,9 @@ enum PathOneInPropertySet {
impl fmt::Display for PathOneInPropertySet { impl fmt::Display for PathOneInPropertySet {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Self::Iri(iri) => write!(f, "{}", iri), Self::Iri(iri) => write!(f, "{iri}"),
Self::A => write!(f, " a "), Self::A => write!(f, " a "),
Self::NegatedIri(iri) => write!(f, "^{}", iri), Self::NegatedIri(iri) => write!(f, "^{iri}"),
Self::NegatedA => write!(f, " ^a "), Self::NegatedA => write!(f, " ^a "),
} }
} }
@ -1058,8 +1058,8 @@ enum TriplesNode {
impl fmt::Display for TriplesNode { impl fmt::Display for TriplesNode {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Self::Collection(p) => write!(f, "{}", p), Self::Collection(p) => write!(f, "{p}"),
Self::BlankNodePropertyList(p) => write!(f, "{}", p), Self::BlankNodePropertyList(p) => write!(f, "{p}"),
} }
} }
} }
@ -1086,8 +1086,8 @@ enum TriplesNodePath {
impl fmt::Display for TriplesNodePath { impl fmt::Display for TriplesNodePath {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Self::CollectionPath(p) => write!(f, "{}", p), Self::CollectionPath(p) => write!(f, "{p}"),
Self::BlankNodePropertyListPath(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 { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "( {}", self.start)?; write!(f, "( {}", self.start)?;
for e in &self.others { for e in &self.others {
write!(f, " {}", e)?; write!(f, " {e}")?;
} }
write!(f, " )") write!(f, " )")
} }
@ -1132,7 +1132,7 @@ impl fmt::Display for CollectionPath {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "( {}", self.start)?; write!(f, "( {}", self.start)?;
for e in &self.others { for e in &self.others {
write!(f, " {}", e)?; write!(f, " {e}")?;
} }
write!(f, " )") write!(f, " )")
} }
@ -1148,8 +1148,8 @@ enum GraphNode {
impl fmt::Display for GraphNode { impl fmt::Display for GraphNode {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Self::VarOrTerm(t) => write!(f, "{}", t), Self::VarOrTerm(t) => write!(f, "{t}"),
Self::TriplesNode(t) => write!(f, "{}", t), Self::TriplesNode(t) => write!(f, "{t}"),
} }
} }
} }
@ -1164,8 +1164,8 @@ enum GraphNodePath {
impl fmt::Display for GraphNodePath { impl fmt::Display for GraphNodePath {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Self::VarOrTerm(t) => write!(f, "{}", t), Self::VarOrTerm(t) => write!(f, "{t}"),
Self::TriplesNodePath(p) => write!(f, "{}", p), Self::TriplesNodePath(p) => write!(f, "{p}"),
} }
} }
} }
@ -1180,8 +1180,8 @@ enum VarOrTerm {
impl fmt::Display for VarOrTerm { impl fmt::Display for VarOrTerm {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Self::Var(v) => write!(f, "{}", v), Self::Var(v) => write!(f, "{v}"),
Self::GraphTerm(t) => write!(f, "{}", t), Self::GraphTerm(t) => write!(f, "{t}"),
} }
} }
} }
@ -1196,8 +1196,8 @@ enum VarOrIri {
impl fmt::Display for VarOrIri { impl fmt::Display for VarOrIri {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Self::Var(v) => write!(f, "{}", v), Self::Var(v) => write!(f, "{v}"),
Self::Iri(t) => write!(f, "{}", t), Self::Iri(t) => write!(f, "{t}"),
} }
} }
} }
@ -1238,8 +1238,8 @@ enum GraphTerm {
impl fmt::Display for GraphTerm { impl fmt::Display for GraphTerm {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Self::Iri(iri) => write!(f, "{}", iri), Self::Iri(iri) => write!(f, "{iri}"),
Self::Literal(l) => write!(f, "{}", l), Self::Literal(l) => write!(f, "{l}"),
Self::Nil => write!(f, " () "), Self::Nil => write!(f, " () "),
} }
} }
@ -1259,7 +1259,7 @@ impl fmt::Display for ConditionalOrExpression {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.start)?; write!(f, "{}", self.start)?;
for e in &self.others { for e in &self.others {
write!(f, " || {}", e)?; write!(f, " || {e}")?;
} }
Ok(()) Ok(())
} }
@ -1276,7 +1276,7 @@ impl fmt::Display for ConditionalAndExpression {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.start)?; write!(f, "{}", self.start)?;
for e in &self.others { for e in &self.others {
write!(f, " && {}", e)?; write!(f, " && {e}")?;
} }
Ok(()) Ok(())
} }
@ -1302,15 +1302,15 @@ enum RelationalExpression {
impl fmt::Display for RelationalExpression { impl fmt::Display for RelationalExpression {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Self::Base(e) => write!(f, "{}", e), Self::Base(e) => write!(f, "{e}"),
Self::Equal(a, b) => write!(f, "{} = {}", a, b), Self::Equal(a, b) => write!(f, "{a} = {b}"),
Self::NotEqual(a, b) => write!(f, "{} != {}", a, b), Self::NotEqual(a, b) => write!(f, "{a} != {b}"),
Self::Less(a, b) => write!(f, "{} < {}", a, b), Self::Less(a, b) => write!(f, "{a} < {b}"),
Self::LessOrEqual(a, b) => write!(f, "{} <= {}", a, b), Self::LessOrEqual(a, b) => write!(f, "{a} <= {b}"),
Self::Greater(a, b) => write!(f, "{} > {}", a, b), Self::Greater(a, b) => write!(f, "{a} > {b}"),
Self::GreaterOrEqual(a, b) => write!(f, "{} >= {}", a, b), Self::GreaterOrEqual(a, b) => write!(f, "{a} >= {b}"),
Self::In(a, b) => write!(f, "{} IN {}", a, b), Self::In(a, b) => write!(f, "{a} IN {b}"),
Self::NotIn(a, b) => write!(f, "{} NOT IN {}", a, b), Self::NotIn(a, b) => write!(f, "{a} NOT IN {b}"),
} }
} }
} }
@ -1329,9 +1329,9 @@ enum AdditiveExpression {
impl fmt::Display for AdditiveExpression { impl fmt::Display for AdditiveExpression {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Self::Base(e) => write!(f, "{}", e), Self::Base(e) => write!(f, "{e}"),
Self::Plus(a, b) => write!(f, "{} + {}", a, b), Self::Plus(a, b) => write!(f, "{a} + {b}"),
Self::Minus(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 { impl fmt::Display for MultiplicativeExpression {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Self::Base(e) => write!(f, "{}", e), Self::Base(e) => write!(f, "{e}"),
Self::Mul(a, b) => write!(f, "{} * {}", a, b), Self::Mul(a, b) => write!(f, "{a} * {b}"),
Self::Div(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 { impl fmt::Display for UnaryExpression {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Self::Not(e) => write!(f, "!{}", e), Self::Not(e) => write!(f, "!{e}"),
Self::Plus(e) => write!(f, "+{}", e), Self::Plus(e) => write!(f, "+{e}"),
Self::Minus(e) => write!(f, "-{}", e), Self::Minus(e) => write!(f, "-{e}"),
Self::Base(e) => write!(f, "{}", e), Self::Base(e) => write!(f, "{e}"),
} }
} }
} }
@ -1387,11 +1387,11 @@ enum PrimaryExpression {
impl fmt::Display for PrimaryExpression { impl fmt::Display for PrimaryExpression {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Self::Bracketted(e) => write!(f, "{}", e), Self::Bracketted(e) => write!(f, "{e}"),
Self::BuiltInCall(e) => write!(f, "{}", e), Self::BuiltInCall(e) => write!(f, "{e}"),
Self::IriOrFunction(e) => write!(f, "{}", e), Self::IriOrFunction(e) => write!(f, "{e}"),
Self::Literal(e) => write!(f, "{}", e), Self::Literal(e) => write!(f, "{e}"),
Self::Var(e) => write!(f, "{}", e), Self::Var(e) => write!(f, "{e}"),
} }
} }
} }
@ -1473,9 +1473,9 @@ enum BuiltInCall {
impl fmt::Display for BuiltInCall { impl fmt::Display for BuiltInCall {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Self::Bound(v) => write!(f, "BOUND({})", v), Self::Bound(v) => write!(f, "BOUND({v})"),
Self::Exists(e) => write!(f, "{}", e), Self::Exists(e) => write!(f, "{e}"),
Self::NotExists(e) => write!(f, "{}", e), Self::NotExists(e) => write!(f, "{e}"),
} }
} }
} }

@ -119,7 +119,7 @@ impl fmt::Display for SyntaxError {
SyntaxErrorKind::Turtle(e) => e.fmt(f), SyntaxErrorKind::Turtle(e) => e.fmt(f),
SyntaxErrorKind::RdfXml(e) => e.fmt(f), SyntaxErrorKind::RdfXml(e) => e.fmt(f),
SyntaxErrorKind::InvalidBaseIri { iri, error } => { SyntaxErrorKind::InvalidBaseIri { iri, error } => {
write!(f, "Invalid base IRI '{}': {}", iri, error) write!(f, "Invalid base IRI '{iri}': {error}")
} }
} }
} }
@ -144,7 +144,7 @@ impl From<SyntaxError> for io::Error {
SyntaxErrorKind::RdfXml(error) => error.into(), SyntaxErrorKind::RdfXml(error) => error.into(),
SyntaxErrorKind::InvalidBaseIri { iri, error } => Self::new( SyntaxErrorKind::InvalidBaseIri { iri, error } => Self::new(
io::ErrorKind::InvalidInput, io::ErrorKind::InvalidInput,
format!("Invalid IRI '{}': {}", iri, error), format!("Invalid IRI '{iri}': {error}"),
), ),
} }
} }

@ -89,7 +89,7 @@ impl<W: Write> TripleWriter<W> {
let triple = triple.into(); let triple = triple.into();
match &mut self.formatter { match &mut self.formatter {
TripleWriterKind::NTriples(writer) => { TripleWriterKind::NTriples(writer) => {
writeln!(writer, "{} .", triple)?; writeln!(writer, "{triple} .")?;
} }
TripleWriterKind::RdfXml(formatter) => formatter.format(&rio::Triple { TripleWriterKind::RdfXml(formatter) => formatter.format(&rio::Triple {
subject: match triple.subject { subject: match triple.subject {
@ -233,7 +233,7 @@ impl<W: Write> QuadWriter<W> {
let quad = quad.into(); let quad = quad.into();
match &mut self.formatter { match &mut self.formatter {
QuadWriterKind::NQuads(writer) => { QuadWriterKind::NQuads(writer) => {
writeln!(writer, "{} .", quad)?; writeln!(writer, "{quad} .")?;
} }
QuadWriterKind::TriG(writer) => { QuadWriterKind::TriG(writer) => {
if quad.graph_name == GraphNameRef::DefaultGraph { if quad.graph_name == GraphNameRef::DefaultGraph {
@ -244,7 +244,7 @@ impl<W: Write> QuadWriter<W> {
TripleRef::from(quad) TripleRef::from(quad)
)?; )?;
} else { } else {
writeln!(writer, "{} .", quad)?; writeln!(writer, "{quad} .")?;
} }
} }
} }

@ -53,7 +53,7 @@ impl fmt::Display for QueryError {
#[inline] #[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match &self.inner { match &self.inner {
QueryErrorKind::Msg { msg } => write!(f, "{}", msg), QueryErrorKind::Msg { msg } => write!(f, "{msg}"),
QueryErrorKind::Other(error) => error.fmt(f), QueryErrorKind::Other(error) => error.fmt(f),
} }
} }

@ -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}$") 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() .unwrap()
.is_match(&buffer), .is_match(&buffer),
"{} is not a valid UUID", "{buffer} is not a valid UUID"
buffer
); );
} }

@ -39,7 +39,7 @@ impl Client {
} }
let content_type = response let content_type = response
.header(&HeaderName::CONTENT_TYPE) .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() .to_str()
.map_err(invalid_data_error)? .map_err(invalid_data_error)?
.to_owned(); .to_owned();
@ -74,7 +74,7 @@ impl Client {
} }
let content_type = response let content_type = response
.header(&HeaderName::CONTENT_TYPE) .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() .to_str()
.map_err(invalid_data_error)? .map_err(invalid_data_error)?
.to_owned(); .to_owned();

@ -754,8 +754,7 @@ impl<'a> PlanBuilder<'a> {
)? )?
} else { } else {
return Err(EvaluationError::msg(format!( return Err(EvaluationError::msg(format!(
"Not supported custom function {}", "Not supported custom function {expression}"
expression
))); )));
} }
} }
@ -796,8 +795,7 @@ impl<'a> PlanBuilder<'a> {
)?))) )?)))
} else { } else {
Err(EvaluationError::msg(format!( Err(EvaluationError::msg(format!(
"The xsd:{} casting takes only one parameter", "The xsd:{name} casting takes only one parameter"
name
))) )))
} }
} }

@ -120,8 +120,7 @@ impl ServiceHandler for SimpleServiceHandler {
)?; )?;
let format = QueryResultsFormat::from_media_type(&content_type).ok_or_else(|| { let format = QueryResultsFormat::from_media_type(&content_type).ok_or_else(|| {
EvaluationError::msg(format!( EvaluationError::msg(format!(
"Unsupported Content-Type returned by {}: {}", "Unsupported Content-Type returned by {service_name}: {content_type}"
service_name, content_type
)) ))
})?; })?;
Ok(QueryResults::read(BufReader::new(body), format)?) Ok(QueryResults::read(BufReader::new(body), format)?)

@ -161,8 +161,7 @@ impl<'a, 'b: 'a> SimpleUpdateEvaluator<'a, 'b> {
)?; )?;
let format = GraphFormat::from_media_type(&content_type).ok_or_else(|| { let format = GraphFormat::from_media_type(&content_type).ok_or_else(|| {
EvaluationError::msg(format!( EvaluationError::msg(format!(
"Unsupported Content-Type returned by {}: {}", "Unsupported Content-Type returned by {from}: {content_type}"
from, content_type
)) ))
})?; })?;
let to_graph_name = match to { let to_graph_name = match to {
@ -187,8 +186,7 @@ impl<'a, 'b: 'a> SimpleUpdateEvaluator<'a, 'b> {
Ok(()) Ok(())
} else { } else {
Err(EvaluationError::msg(format!( Err(EvaluationError::msg(format!(
"The graph {} already exists", "The graph {graph_name} already exists"
graph_name
))) )))
} }
} }
@ -206,8 +204,7 @@ impl<'a, 'b: 'a> SimpleUpdateEvaluator<'a, 'b> {
Ok(()) Ok(())
} else { } else {
Err(EvaluationError::msg(format!( Err(EvaluationError::msg(format!(
"The graph {} does not exists", "The graph {graph} does not exists"
graph
))) )))
} }
} }
@ -227,8 +224,7 @@ impl<'a, 'b: 'a> SimpleUpdateEvaluator<'a, 'b> {
Ok(()) Ok(())
} else { } else {
Err(EvaluationError::msg(format!( Err(EvaluationError::msg(format!(
"The graph {} does not exists", "The graph {graph_name} does not exists"
graph_name
))) )))
} }
} }

@ -175,8 +175,8 @@ impl Db {
return Err(io::Error::new( return Err(io::Error::new(
io::ErrorKind::Other, io::ErrorKind::Other,
format!( format!(
"Oxigraph needs at least 96 file descriptors, only {} allowed. Run e.g. `ulimit -n 512` to allow 512 opened files", "Oxigraph needs at least 96 file descriptors, only {available_fd} allowed. Run e.g. `ulimit -n 512` to allow 512 opened files"
available_fd
), ),
) )
.into()); .into());
@ -1123,7 +1123,7 @@ fn path_to_cstring(path: &Path) -> Result<CString, StorageError> {
.map_err(|e| { .map_err(|e| {
io::Error::new( io::Error::new(
io::ErrorKind::InvalidInput, io::ErrorKind::InvalidInput,
format!("The DB path contains null bytes: {}", e), format!("The DB path contains null bytes: {e}"),
) )
})?) })?)
} }

@ -200,13 +200,13 @@ impl Storage {
match version { match version {
_ if version < LATEST_STORAGE_VERSION => Err(CorruptionError::msg(format!( _ 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", "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"
version
)).into()), )).into()),
LATEST_STORAGE_VERSION => Ok(()), LATEST_STORAGE_VERSION => Ok(()),
_ => Err(CorruptionError::msg(format!( _ => Err(CorruptionError::msg(format!(
"The RocksDB database is using the too recent version {}. Upgrade to the latest Oxigraph version to load this database", "The RocksDB database is using the too recent version {version}. Upgrade to the latest Oxigraph version to load this database"
version
)).into()) )).into())
} }
} }
@ -216,7 +216,7 @@ impl Storage {
Ok( Ok(
if let Some(version) = self.db.get(&self.default_cf, b"oxversion")? { if let Some(version) = self.db.get(&self.default_cf, b"oxversion")? {
u64::from_be_bytes(version.as_ref().try_into().map_err(|e| { 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 { } else {
self.update_version(LATEST_STORAGE_VERSION)?; self.update_version(LATEST_STORAGE_VERSION)?;

@ -987,8 +987,7 @@ impl<S: StrLookup> Decoder for S {
fn get_required_str<L: StrLookup>(lookup: &L, id: &StrHash) -> Result<String, StorageError> { fn get_required_str<L: StrLookup>(lookup: &L, id: &StrHash) -> Result<String, StorageError> {
Ok(lookup.get_str(id)?.ok_or_else(|| { Ok(lookup.get_str(id)?.ok_or_else(|| {
CorruptionError::new(format!( CorruptionError::new(format!(
"Not able to find the string with id {:?} in the string store", "Not able to find the string with id {id:?} in the string store"
id
)) ))
})?) })?)
} }

@ -184,8 +184,7 @@ impl fmt::Display for BadSmallStringError {
match self { match self {
Self::TooLong(v) => write!( Self::TooLong(v) => write!(
f, f,
"small strings could only contain at most 15 characters, found {}", "small strings could only contain at most 15 characters, found {v}"
v
), ),
Self::BadUtf8(e) => e.fmt(f), Self::BadUtf8(e) => e.fmt(f),
} }

@ -217,7 +217,7 @@ impl fmt::Display for DateTime {
self.second() self.second()
)?; )?;
if let Some(timezone_offset) = self.timezone_offset() { if let Some(timezone_offset) = self.timezone_offset() {
write!(f, "{}", timezone_offset)?; write!(f, "{timezone_offset}")?;
} }
Ok(()) Ok(())
} }
@ -372,7 +372,7 @@ impl fmt::Display for Time {
self.second() self.second()
)?; )?;
if let Some(timezone_offset) = self.timezone_offset() { if let Some(timezone_offset) = self.timezone_offset() {
write!(f, "{}", timezone_offset)?; write!(f, "{timezone_offset}")?;
} }
Ok(()) Ok(())
} }
@ -522,7 +522,7 @@ impl fmt::Display for Date {
} }
write!(f, "{:04}-{:02}-{:02}", year.abs(), self.month(), self.day())?; write!(f, "{:04}-{:02}-{:02}", year.abs(), self.month(), self.day())?;
if let Some(timezone_offset) = self.timezone_offset() { if let Some(timezone_offset) = self.timezone_offset() {
write!(f, "{}", timezone_offset)?; write!(f, "{timezone_offset}")?;
} }
Ok(()) Ok(())
} }
@ -622,7 +622,7 @@ impl fmt::Display for GYearMonth {
} }
write!(f, "{:04}-{:02}", year.abs(), self.month())?; write!(f, "{:04}-{:02}", year.abs(), self.month())?;
if let Some(timezone_offset) = self.timezone_offset() { if let Some(timezone_offset) = self.timezone_offset() {
write!(f, "{}", timezone_offset)?; write!(f, "{timezone_offset}")?;
} }
Ok(()) Ok(())
} }
@ -721,7 +721,7 @@ impl fmt::Display for GYear {
} }
write!(f, "{:04}", year.abs())?; write!(f, "{:04}", year.abs())?;
if let Some(timezone_offset) = self.timezone_offset() { if let Some(timezone_offset) = self.timezone_offset() {
write!(f, "{}", timezone_offset)?; write!(f, "{timezone_offset}")?;
} }
Ok(()) Ok(())
} }
@ -817,7 +817,7 @@ impl fmt::Display for GMonthDay {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "--{:02}-{:02}", self.month(), self.day())?; write!(f, "--{:02}-{:02}", self.month(), self.day())?;
if let Some(timezone_offset) = self.timezone_offset() { if let Some(timezone_offset) = self.timezone_offset() {
write!(f, "{}", timezone_offset)?; write!(f, "{timezone_offset}")?;
} }
Ok(()) Ok(())
} }
@ -920,7 +920,7 @@ impl fmt::Display for GMonth {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "--{:02}", self.month())?; write!(f, "--{:02}", self.month())?;
if let Some(timezone_offset) = self.timezone_offset() { if let Some(timezone_offset) = self.timezone_offset() {
write!(f, "{}", timezone_offset)?; write!(f, "{timezone_offset}")?;
} }
Ok(()) Ok(())
} }
@ -1015,7 +1015,7 @@ impl fmt::Display for GDay {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "---{:02}", self.day())?; write!(f, "---{:02}", self.day())?;
if let Some(timezone_offset) = self.timezone_offset() { if let Some(timezone_offset) = self.timezone_offset() {
write!(f, "{}", timezone_offset)?; write!(f, "{timezone_offset}")?;
} }
Ok(()) Ok(())
} }
@ -1514,7 +1514,7 @@ impl fmt::Display for DateTimeError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match &self.kind { match &self.kind {
DateTimeErrorKind::InvalidDayOfMonth { day, month } => { 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::Overflow => write!(f, "Overflow during date time normalization"),
DateTimeErrorKind::SystemTime(error) => error.fmt(f), DateTimeErrorKind::SystemTime(error) => error.fmt(f),

@ -134,12 +134,12 @@ impl fmt::Display for Duration {
if y != 0 { if y != 0 {
if m == 0 { if m == 0 {
write!(f, "{}Y", y)?; write!(f, "{y}Y")?;
} else { } else {
write!(f, "{}Y{}M", y, m)?; write!(f, "{y}Y{m}M")?;
} }
} else if m != 0 || ss == 0.into() { } 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 .unwrap(); //could not fail
if d != 0 { if d != 0 {
write!(f, "{}D", d)?; write!(f, "{d}D")?;
} }
if h != 0 || m != 0 || s != 0.into() { if h != 0 || m != 0 || s != 0.into() {
write!(f, "T")?; write!(f, "T")?;
if h != 0 { if h != 0 {
write!(f, "{}H", h)?; write!(f, "{h}H")?;
} }
if m != 0 { if m != 0 {
write!(f, "{}M", m)?; write!(f, "{m}M")?;
} }
if s != 0.into() { if s != 0.into() {
write!(f, "{}S", s)?; write!(f, "{s}S")?;
} }
} }
} }

@ -41,29 +41,27 @@ impl fmt::Display for XsdParseError {
write!(f, "Invalid XML Schema value: {}", kind.description()) write!(f, "Invalid XML Schema value: {}", kind.description())
} }
XsdParseErrorKind::NomChar(c) => { 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) => { XsdParseErrorKind::MissingData(Needed::Unknown) => {
write!(f, "Too small XML Schema value") write!(f, "Too small XML Schema value")
} }
XsdParseErrorKind::MissingData(Needed::Size(size)) => { 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 } => { 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::Overflow => write!(f, "Computation overflow or underflow"),
XsdParseErrorKind::ParseInt(error) => { XsdParseErrorKind::ParseInt(error) => {
write!(f, "Error while parsing integer: {}", error) write!(f, "Error while parsing integer: {error}")
} }
XsdParseErrorKind::ParseDecimal(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), XsdParseErrorKind::DateTime(error) => error.fmt(f),
} }
} }

@ -8,7 +8,7 @@ fn link(name: &str, bundled: bool) {
let target = var("TARGET").unwrap(); let target = var("TARGET").unwrap();
let target: Vec<_> = target.split('-').collect(); let target: Vec<_> = target.split('-').collect();
if target.get(2) == Some(&"windows") { 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") { if bundled && target.get(3) == Some(&"gnu") {
let dir = var("CARGO_MANIFEST_DIR").unwrap(); let dir = var("CARGO_MANIFEST_DIR").unwrap();
println!("cargo:rustc-link-search=native={}/{}", dir, target[0]); println!("cargo:rustc-link-search=native={}/{}", dir, target[0]);

@ -83,8 +83,7 @@ pub fn parse(
.into_py(py)) .into_py(py))
} else { } else {
Err(PyValueError::new_err(format!( Err(PyValueError::new_err(format!(
"Not supported MIME type: {}", "Not supported MIME type: {mime_type}"
mime_type
))) )))
} }
} }
@ -150,8 +149,7 @@ pub fn serialize(input: &PyAny, output: PyObject, mime_type: &str, py: Python<'_
Ok(()) Ok(())
} else { } else {
Err(PyValueError::new_err(format!( Err(PyValueError::new_err(format!(
"Not supported MIME type: {}", "Not supported MIME type: {mime_type}"
mime_type
))) )))
} }
} }

@ -324,8 +324,7 @@ impl PyStore {
.map_err(map_loader_error) .map_err(map_loader_error)
} else { } else {
Err(PyValueError::new_err(format!( Err(PyValueError::new_err(format!(
"Not supported MIME type: {}", "Not supported MIME type: {mime_type}"
mime_type
))) )))
} }
}) })
@ -411,8 +410,7 @@ impl PyStore {
.map_err(map_loader_error) .map_err(map_loader_error)
} else { } else {
Err(PyValueError::new_err(format!( Err(PyValueError::new_err(format!(
"Not supported MIME type: {}", "Not supported MIME type: {mime_type}"
mime_type
))) )))
} }
}) })
@ -488,8 +486,7 @@ impl PyStore {
.map_err(map_serializer_error) .map_err(map_serializer_error)
} else { } else {
Err(PyValueError::new_err(format!( Err(PyValueError::new_err(format!(
"Not supported MIME type: {}", "Not supported MIME type: {mime_type}"
mime_type
))) )))
} }
}) })

@ -76,7 +76,7 @@ pub fn main() -> anyhow::Result<()> {
Command::Load { file, lenient } => { Command::Load { file, lenient } => {
ThreadPoolBuilder::new() ThreadPoolBuilder::new()
.num_threads(max(1, available_parallelism()?.get() / 2)) .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()? .build()?
.scope(|s| { .scope(|s| {
for file in file { for file in file {
@ -177,8 +177,7 @@ impl GraphOrDatasetFormat {
if let Some(ext) = path.extension().and_then(|ext| ext.to_str()) { if let Some(ext) = path.extension().and_then(|ext| ext.to_str()) {
Self::from_extension(ext).map_err(|e| { Self::from_extension(ext).map_err(|e| {
e.context(format!( e.context(format!(
"Not able to guess the file format from file name extension '{}'", "Not able to guess the file format from file name extension '{ext}'"
ext
)) ))
}) })
} else { } else {
@ -416,7 +415,7 @@ fn handle_request(request: &mut Request, store: Store) -> Result<Response, HttpE
} else { } else {
return Err(( return Err((
Status::NOT_FOUND, Status::NOT_FOUND,
format!("The graph {} does not exists", target), format!("The graph {target} does not exists"),
)); ));
} }
} }
@ -847,7 +846,7 @@ fn content_negotiation<F>(
let (possible, parameters) = possible.split_once(';').unwrap_or((possible, "")); let (possible, parameters) = possible.split_once(';').unwrap_or((possible, ""));
let (possible_base, possible_sub) = possible let (possible_base, possible_sub) = possible
.split_once('/') .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_base = possible_base.trim();
let possible_sub = possible_sub.trim(); let possible_sub = possible_sub.trim();
@ -856,7 +855,7 @@ fn content_negotiation<F>(
let parameter = parameter.trim(); let parameter = parameter.trim();
if let Some(s) = parameter.strip_prefix("q=") { if let Some(s) = parameter.strip_prefix("q=") {
score = f32::from_str(s.trim()) 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 { if score <= result_score {
@ -868,7 +867,7 @@ fn content_negotiation<F>(
.map_or(*candidate, |(p, _)| p) .map_or(*candidate, |(p, _)| p)
.split_once('/') .split_once('/')
.ok_or_else(|| { .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 == "*") if (possible_base == candidate_base || possible_base == "*")
&& (possible_sub == candidate_sub || possible_sub == "*") && (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() { if url_query_parameter(request, "lenient").is_some() {
loader = loader.on_parse_error(move |e| { loader = loader.on_parse_error(move |e| {
eprintln!("Parsing error: {}", e); eprintln!("Parsing error: {e}");
Ok(()) Ok(())
}) })
} }
@ -976,12 +975,12 @@ fn bad_request(message: impl fmt::Display) -> HttpError {
fn unsupported_media_type(content_type: &str) -> HttpError { fn unsupported_media_type(content_type: &str) -> HttpError {
( (
Status::UNSUPPORTED_MEDIA_TYPE, 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 { 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()) (Status::INTERNAL_SERVER_ERROR, message.to_string())
} }
@ -1033,7 +1032,7 @@ impl<O, U: (Fn(O) -> io::Result<Option<O>>)> Read for ReadForWrite<O, U> {
self.state = match (self.add_more_data)(state) { self.state = match (self.add_more_data)(state) {
Ok(state) => state, Ok(state) => state,
Err(e) => { Err(e) => {
eprintln!("Internal server error while streaming results: {}", e); eprintln!("Internal server error while streaming results: {e}");
self.buffer self.buffer
.borrow_mut() .borrow_mut()
.write_all(e.to_string().as_bytes())?; .write_all(e.to_string().as_bytes())?;
@ -1721,7 +1720,7 @@ mod tests {
let mut response = self.exec(request); let mut response = self.exec(request);
let mut buf = String::new(); let mut buf = String::new();
response.body_mut().read_to_string(&mut buf)?; 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(()) Ok(())
} }
@ -1729,7 +1728,7 @@ mod tests {
let mut response = self.exec(request); let mut response = self.exec(request);
let mut buf = String::new(); let mut buf = String::new();
response.body_mut().read_to_string(&mut buf)?; 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); assert_eq!(&buf, expected_body);
Ok(()) Ok(())
} }

@ -25,25 +25,25 @@ impl fmt::Display for Test {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.kind)?; write!(f, "{}", self.kind)?;
for name in &self.name { for name in &self.name {
write!(f, " named \"{}\"", name)?; write!(f, " named \"{name}\"")?;
} }
for comment in &self.comment { for comment in &self.comment {
write!(f, " with comment \"{}\"", comment)?; write!(f, " with comment \"{comment}\"")?;
} }
if let Some(action) = &self.action { if let Some(action) = &self.action {
write!(f, " on file \"{}\"", action)?; write!(f, " on file \"{action}\"")?;
} }
if let Some(query) = &self.query { if let Some(query) = &self.query {
write!(f, " on query {}", &query)?; write!(f, " on query {}", &query)?;
} }
for data in &self.data { for data in &self.data {
write!(f, " with data {}", data)?; write!(f, " with data {data}")?;
} }
for (_, data) in &self.graph_data { for (_, data) in &self.graph_data {
write!(f, " and graph data {}", data)?; write!(f, " and graph data {data}")?;
} }
for result in &self.result { for result in &self.result {
write!(f, " and expected result {}", result)?; write!(f, " and expected result {result}")?;
} }
Ok(()) Ok(())
} }

@ -70,7 +70,7 @@ fn evaluate_positive_syntax_test(test: &Test) -> Result<()> {
.ok_or_else(|| anyhow!("No action found for test {}", test))?; .ok_or_else(|| anyhow!("No action found for test {}", test))?;
match load_dataset(action) { match load_dataset(action) {
Ok(_) => Ok(()), Ok(_) => Ok(()),
Err(e) => Err(anyhow!(format!("Parse error: {}", e))), Err(e) => Err(anyhow!(format!("Parse error: {e}"))),
} }
} }

@ -414,7 +414,7 @@ impl ServiceHandler for StaticServiceHandler {
.ok_or_else(|| { .ok_or_else(|| {
io::Error::new( io::Error::new(
io::ErrorKind::InvalidInput, io::ErrorKind::InvalidInput,
format!("Service {} not found", service_name), format!("Service {service_name} not found"),
) )
})? })?
.query_opt( .query_opt(
@ -579,12 +579,12 @@ impl fmt::Display for StaticQueryResults {
} => { } => {
write!(f, "Variables:")?; write!(f, "Variables:")?;
for v in variables { for v in variables {
write!(f, " {}", v)?; write!(f, " {v}")?;
} }
for solution in solutions { for solution in solutions {
write!(f, "\n{{")?; write!(f, "\n{{")?;
for (k, v) in solution { for (k, v) in solution {
write!(f, "{} = {} ", k, v)?; write!(f, "{k} = {v} ")?;
} }
write!(f, "}}")?; write!(f, "}}")?;
} }

Loading…
Cancel
Save