diff --git a/lib/oxrdf/src/dataset.rs b/lib/oxrdf/src/dataset.rs index 05ccbb56..95ecef75 100644 --- a/lib/oxrdf/src/dataset.rs +++ b/lib/oxrdf/src/dataset.rs @@ -29,6 +29,7 @@ use crate::interning::*; use crate::SubjectRef; use crate::*; +use std::cmp::min; use std::collections::hash_map::DefaultHasher; use std::collections::BTreeSet; use std::collections::{HashMap, HashSet}; @@ -705,7 +706,7 @@ impl Dataset { InternedTerm, InternedGraphName, )> { - let b_prime = partition.iter().find_map(|(_, b)| (b.len() > 1).then(|| b)); + let b_prime = partition.iter().map(|(_, b)| b).find(|b| b.len() > 1); if let Some(b_prime) = b_prime { b_prime .iter() @@ -715,17 +716,7 @@ impl Dataset { let (hash_prime_prime, partition_prime) = self.hash_bnodes(hash_prime); self.distinguish(&hash_prime_prime, &partition_prime) }) - .fold(None, |a, b| { - Some(if let Some(a) = a { - if a <= b { - a - } else { - b - } - } else { - b - }) - }) + .reduce(min) .unwrap_or_default() } else { self.label(hash) diff --git a/lib/oxrdf/src/interning.rs b/lib/oxrdf/src/interning.rs index 54c8acde..02d229e0 100644 --- a/lib/oxrdf/src/interning.rs +++ b/lib/oxrdf/src/interning.rs @@ -466,7 +466,7 @@ impl InternedTriple { interner .triples .contains_key(&interned_triple) - .then(|| interned_triple) + .then_some(interned_triple) } pub fn next(&self) -> Self { diff --git a/lib/spargebra/src/parser.rs b/lib/spargebra/src/parser.rs index 7779e31c..fbe7af91 100644 --- a/lib/spargebra/src/parser.rs +++ b/lib/spargebra/src/parser.rs @@ -736,7 +736,7 @@ impl ParserState { let aggregates = self.aggregates.last_mut().ok_or("Unexpected aggregate")?; Ok(aggregates .iter() - .find_map(|(v, a)| (a == &agg).then(|| v)) + .find_map(|(v, a)| (a == &agg).then_some(v)) .cloned() .unwrap_or_else(|| { let new_var = variable(); diff --git a/lib/src/sparql/eval.rs b/lib/src/sparql/eval.rs index 8c94853d..f4620f56 100644 --- a/lib/src/sparql/eval.rs +++ b/lib/src/sparql/eval.rs @@ -2321,7 +2321,7 @@ fn to_argument_compatible_strings( ) -> Option<(String, String, Option)> { let (value1, language1) = to_string_and_language(dataset, arg1)?; let (value2, language2) = to_string_and_language(dataset, arg2)?; - (language2.is_none() || language1 == language2).then(|| (value1, value2, language1)) + (language2.is_none() || language1 == language2).then_some((value1, value2, language1)) } pub(super) fn compile_pattern(pattern: &str, flags: Option<&str>) -> Option { @@ -3080,10 +3080,10 @@ fn put_pattern_value( tuple: &mut EncodedTuple, ) -> Option<()> { match selector { - TupleSelector::Constant(c) => (*c == value).then(|| ()), + TupleSelector::Constant(c) => (*c == value).then_some(()), TupleSelector::Variable(v) => { if let Some(old) = tuple.get(*v) { - (value == *old).then(|| ()) + (value == *old).then_some(()) } else { tuple.set(*v, value); Some(()) @@ -3161,7 +3161,7 @@ impl PathEvaluator { .and_then(|middle| { Ok(self .eval_closed_in_graph(b, &middle, end, graph_name)? - .then(|| ())) + .then_some(())) }) .transpose() }) @@ -3232,7 +3232,7 @@ impl PathEvaluator { Box::new(self.eval_from_in_unknown_graph(a, start).flat_map_ok( move |(middle, graph_name)| { eval.eval_closed_in_graph(&b, &middle, &end, &graph_name) - .map(|is_found| is_found.then(|| graph_name)) + .map(|is_found| is_found.then_some(graph_name)) .transpose() }, )) @@ -3252,7 +3252,7 @@ impl PathEvaluator { |e| eval.eval_from_in_graph(&p, &e, &graph_name), &end, ) - .map(|is_found| is_found.then(|| graph_name)) + .map(|is_found| is_found.then_some(graph_name)) .transpose() }) } @@ -3269,7 +3269,7 @@ impl PathEvaluator { |e| eval.eval_from_in_graph(&p, &e, &graph_name), &end, ) - .map(|is_found| is_found.then(|| graph_name)) + .map(|is_found| is_found.then_some(graph_name)) }) .transpose() }), @@ -3285,7 +3285,7 @@ impl PathEvaluator { let p = Rc::clone(p); self.run_if_term_is_a_dataset_node(start, move |graph_name| { eval.eval_closed_in_graph(&p, &start2, &end, &graph_name) - .map(|is_found| is_found.then(|| graph_name)) + .map(|is_found| is_found.then_some(graph_name)) .transpose() }) } diff --git a/lib/src/sparql/plan_builder.rs b/lib/src/sparql/plan_builder.rs index 5e7370c1..7d985504 100644 --- a/lib/src/sparql/plan_builder.rs +++ b/lib/src/sparql/plan_builder.rs @@ -1223,7 +1223,7 @@ impl<'a> PlanBuilder<'a> { let encoded = if let Some(to_id) = to .iter() .enumerate() - .find_map(|(to_id, var)| (*var == from_variable.plain).then(|| to_id)) + .find_map(|(to_id, var)| (*var == from_variable.plain).then_some(to_id)) { to_id } else { diff --git a/lib/src/storage/backend/fallback.rs b/lib/src/storage/backend/fallback.rs index 6000863b..1c156111 100644 --- a/lib/src/storage/backend/fallback.rs +++ b/lib/src/storage/backend/fallback.rs @@ -32,7 +32,7 @@ impl Db { #[allow(clippy::unwrap_in_result)] pub fn column_family(&self, name: &'static str) -> Option { let name = ColumnFamily(name); - (self.0.read().unwrap().contains_key(&name)).then(|| name) + self.0.read().unwrap().contains_key(&name).then_some(name) } #[must_use] diff --git a/lib/src/storage/backend/rocksdb.rs b/lib/src/storage/backend/rocksdb.rs index fc8f4da2..81577551 100644 --- a/lib/src/storage/backend/rocksdb.rs +++ b/lib/src/storage/backend/rocksdb.rs @@ -393,7 +393,7 @@ impl Db { cf_handles, cf_options, is_secondary: true, - path_to_remove: in_memory.then(|| secondary_path), + path_to_remove: in_memory.then_some(secondary_path), })), }) } @@ -1001,7 +1001,7 @@ impl Reader { break; } } - found.then(|| bound) + found.then_some(bound) }; unsafe {