Makes Clippy 1.65 happy

pull/543/head
Tpt 2 years ago
parent ae294683d6
commit c016116b09
  1. 15
      lib/oxrdf/src/dataset.rs
  2. 2
      lib/oxrdf/src/interning.rs
  3. 2
      lib/spargebra/src/parser.rs
  4. 16
      lib/src/sparql/eval.rs
  5. 2
      lib/src/sparql/plan_builder.rs
  6. 2
      lib/src/storage/backend/fallback.rs
  7. 4
      lib/src/storage/backend/rocksdb.rs

@ -29,6 +29,7 @@
use crate::interning::*; use crate::interning::*;
use crate::SubjectRef; use crate::SubjectRef;
use crate::*; use crate::*;
use std::cmp::min;
use std::collections::hash_map::DefaultHasher; use std::collections::hash_map::DefaultHasher;
use std::collections::BTreeSet; use std::collections::BTreeSet;
use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet};
@ -705,7 +706,7 @@ impl Dataset {
InternedTerm, InternedTerm,
InternedGraphName, 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 { if let Some(b_prime) = b_prime {
b_prime b_prime
.iter() .iter()
@ -715,17 +716,7 @@ impl Dataset {
let (hash_prime_prime, partition_prime) = self.hash_bnodes(hash_prime); let (hash_prime_prime, partition_prime) = self.hash_bnodes(hash_prime);
self.distinguish(&hash_prime_prime, &partition_prime) self.distinguish(&hash_prime_prime, &partition_prime)
}) })
.fold(None, |a, b| { .reduce(min)
Some(if let Some(a) = a {
if a <= b {
a
} else {
b
}
} else {
b
})
})
.unwrap_or_default() .unwrap_or_default()
} else { } else {
self.label(hash) self.label(hash)

@ -466,7 +466,7 @@ impl InternedTriple {
interner interner
.triples .triples
.contains_key(&interned_triple) .contains_key(&interned_triple)
.then(|| interned_triple) .then_some(interned_triple)
} }
pub fn next(&self) -> Self { pub fn next(&self) -> Self {

@ -736,7 +736,7 @@ impl ParserState {
let aggregates = self.aggregates.last_mut().ok_or("Unexpected aggregate")?; let aggregates = self.aggregates.last_mut().ok_or("Unexpected aggregate")?;
Ok(aggregates Ok(aggregates
.iter() .iter()
.find_map(|(v, a)| (a == &agg).then(|| v)) .find_map(|(v, a)| (a == &agg).then_some(v))
.cloned() .cloned()
.unwrap_or_else(|| { .unwrap_or_else(|| {
let new_var = variable(); let new_var = variable();

@ -2321,7 +2321,7 @@ fn to_argument_compatible_strings(
) -> Option<(String, String, Option<SmallStringOrId>)> { ) -> Option<(String, String, Option<SmallStringOrId>)> {
let (value1, language1) = to_string_and_language(dataset, arg1)?; let (value1, language1) = to_string_and_language(dataset, arg1)?;
let (value2, language2) = to_string_and_language(dataset, arg2)?; 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<Regex> { pub(super) fn compile_pattern(pattern: &str, flags: Option<&str>) -> Option<Regex> {
@ -3080,10 +3080,10 @@ fn put_pattern_value(
tuple: &mut EncodedTuple, tuple: &mut EncodedTuple,
) -> Option<()> { ) -> Option<()> {
match selector { match selector {
TupleSelector::Constant(c) => (*c == value).then(|| ()), TupleSelector::Constant(c) => (*c == value).then_some(()),
TupleSelector::Variable(v) => { TupleSelector::Variable(v) => {
if let Some(old) = tuple.get(*v) { if let Some(old) = tuple.get(*v) {
(value == *old).then(|| ()) (value == *old).then_some(())
} else { } else {
tuple.set(*v, value); tuple.set(*v, value);
Some(()) Some(())
@ -3161,7 +3161,7 @@ impl PathEvaluator {
.and_then(|middle| { .and_then(|middle| {
Ok(self Ok(self
.eval_closed_in_graph(b, &middle, end, graph_name)? .eval_closed_in_graph(b, &middle, end, graph_name)?
.then(|| ())) .then_some(()))
}) })
.transpose() .transpose()
}) })
@ -3232,7 +3232,7 @@ impl PathEvaluator {
Box::new(self.eval_from_in_unknown_graph(a, start).flat_map_ok( Box::new(self.eval_from_in_unknown_graph(a, start).flat_map_ok(
move |(middle, graph_name)| { move |(middle, graph_name)| {
eval.eval_closed_in_graph(&b, &middle, &end, &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() .transpose()
}, },
)) ))
@ -3252,7 +3252,7 @@ impl PathEvaluator {
|e| eval.eval_from_in_graph(&p, &e, &graph_name), |e| eval.eval_from_in_graph(&p, &e, &graph_name),
&end, &end,
) )
.map(|is_found| is_found.then(|| graph_name)) .map(|is_found| is_found.then_some(graph_name))
.transpose() .transpose()
}) })
} }
@ -3269,7 +3269,7 @@ impl PathEvaluator {
|e| eval.eval_from_in_graph(&p, &e, &graph_name), |e| eval.eval_from_in_graph(&p, &e, &graph_name),
&end, &end,
) )
.map(|is_found| is_found.then(|| graph_name)) .map(|is_found| is_found.then_some(graph_name))
}) })
.transpose() .transpose()
}), }),
@ -3285,7 +3285,7 @@ impl PathEvaluator {
let p = Rc::clone(p); let p = Rc::clone(p);
self.run_if_term_is_a_dataset_node(start, move |graph_name| { self.run_if_term_is_a_dataset_node(start, move |graph_name| {
eval.eval_closed_in_graph(&p, &start2, &end, &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() .transpose()
}) })
} }

@ -1223,7 +1223,7 @@ impl<'a> PlanBuilder<'a> {
let encoded = if let Some(to_id) = to let encoded = if let Some(to_id) = to
.iter() .iter()
.enumerate() .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 to_id
} else { } else {

@ -32,7 +32,7 @@ impl Db {
#[allow(clippy::unwrap_in_result)] #[allow(clippy::unwrap_in_result)]
pub fn column_family(&self, name: &'static str) -> Option<ColumnFamily> { pub fn column_family(&self, name: &'static str) -> Option<ColumnFamily> {
let name = ColumnFamily(name); 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] #[must_use]

@ -393,7 +393,7 @@ impl Db {
cf_handles, cf_handles,
cf_options, cf_options,
is_secondary: true, 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; break;
} }
} }
found.then(|| bound) found.then_some(bound)
}; };
unsafe { unsafe {

Loading…
Cancel
Save