diff --git a/lib/src/lib.rs b/lib/src/lib.rs index b1cc7668..69c37cc3 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs @@ -52,6 +52,10 @@ )] #![doc(html_favicon_url = "https://raw.githubusercontent.com/oxigraph/oxigraph/master/logo.svg")] #![doc(html_logo_url = "https://raw.githubusercontent.com/oxigraph/oxigraph/master/logo.svg")] +#![allow( + clippy::multiple_crate_versions, //TODO + clippy::rc_buffer //TODO: enforce +)] #![warn( clippy::cast_lossless, clippy::cast_possible_truncation, diff --git a/lib/src/model/parser.rs b/lib/src/model/parser.rs index 16a8ea22..4a8e2ded 100644 --- a/lib/src/model/parser.rs +++ b/lib/src/model/parser.rs @@ -80,28 +80,28 @@ impl FromStr for Literal { /// assert_eq!(Literal::from_str("-122e+1").unwrap(), Literal::new_typed_literal("-122e+1", xsd::DOUBLE)); /// ``` fn from_str(s: &str) -> Result { - if s.starts_with('"') { - let mut value = String::with_capacity(s.len() - 2); - let mut chars = s[1..].chars(); + if let Some(s) = s.strip_prefix('"') { + let mut value = String::with_capacity(s.len() - 1); + let mut chars = s.chars(); while let Some(c) = chars.next() { match c { '"' => { let remain = chars.as_str(); return if remain.is_empty() { Ok(Literal::new_simple_literal(value)) - } else if remain.starts_with('@') { + } else if let Some(language) = remain.strip_prefix('@') { Literal::new_language_tagged_literal(value, &remain[1..]).map_err( |error| TermParseError { kind: TermParseErrorKind::LanguageTag { - value: remain[1..].to_owned(), + value: language.to_owned(), error, }, }, ) - } else if remain.starts_with("^^") { + } else if let Some(datatype) = remain.strip_prefix("^^") { Ok(Literal::new_typed_literal( value, - NamedNode::from_str(&remain[2..])?, + NamedNode::from_str(datatype)?, )) } else { Err(TermParseError::msg("Unexpected characters after a literal")) diff --git a/lib/src/model/xsd/date_time.rs b/lib/src/model/xsd/date_time.rs index 3f68a1d2..90f04873 100644 --- a/lib/src/model/xsd/date_time.rs +++ b/lib/src/model/xsd/date_time.rs @@ -1155,7 +1155,7 @@ impl Timestamp { Ok(Self { timezone_offset: props.timezone_offset, - value: time_on_timeline(props).ok_or_else(|| DateTimeError { + value: time_on_timeline(props).ok_or(DateTimeError { kind: DateTimeErrorKind::Overflow, })?, }) diff --git a/lib/src/sparql/parser.rs b/lib/src/sparql/parser.rs index 8a60d193..bb38e4d3 100644 --- a/lib/src/sparql/parser.rs +++ b/lib/src/sparql/parser.rs @@ -421,10 +421,7 @@ impl ParserState { } fn new_aggregation(&mut self, agg: Aggregation) -> Result { - let aggregations = self - .aggregations - .last_mut() - .ok_or_else(|| "Unexpected aggregate")?; + let aggregations = self.aggregations.last_mut().ok_or("Unexpected aggregate")?; Ok(aggregations .iter() .find_map(|(a, v)| if a == &agg { Some(v) } else { None }) diff --git a/lib/src/sparql/plan.rs b/lib/src/sparql/plan.rs index 2184a4ec..2e54f268 100644 --- a/lib/src/sparql/plan.rs +++ b/lib/src/sparql/plan.rs @@ -500,7 +500,7 @@ impl EncodedTuple { self.inner.get(index).cloned().unwrap_or(None) } - pub fn iter<'a>(&'a self) -> impl Iterator>> + 'a { + pub fn iter(&self) -> impl Iterator>> + '_ { self.inner.iter().cloned() } diff --git a/lib/src/store/memory.rs b/lib/src/store/memory.rs index 09fb8846..546f86f6 100644 --- a/lib/src/store/memory.rs +++ b/lib/src/store/memory.rs @@ -1033,13 +1033,13 @@ fn remove_from_quad_map(quad_map: &mut QuadMap, e1: &T, e2: &T, } } -fn option_set_flatten<'a, T: Clone>(i: Option<&'a HashSet>) -> impl Iterator + 'a { +fn option_set_flatten(i: Option<&HashSet>) -> impl Iterator + '_ { i.into_iter().flat_map(|s| s.iter().cloned()) } -fn option_pair_map_flatten<'a, T: Copy>( - i: Option<&'a HashMap>>, -) -> impl Iterator + 'a { +fn option_pair_map_flatten( + i: Option<&HashMap>>, +) -> impl Iterator + '_ { i.into_iter().flat_map(|kv| { kv.iter().flat_map(|(k, vs)| { let k = *k; @@ -1048,7 +1048,7 @@ fn option_pair_map_flatten<'a, T: Copy>( }) } -fn triple_map_flatten<'a, T: Copy>(spo: &'a TripleMap) -> impl Iterator + 'a { +fn triple_map_flatten(spo: &TripleMap) -> impl Iterator + '_ { spo.iter().flat_map(|(s, po)| { let s = *s; po.iter().flat_map(move |(p, os)| { @@ -1058,9 +1058,9 @@ fn triple_map_flatten<'a, T: Copy>(spo: &'a TripleMap) -> impl Iterator( - i: Option<&'a TripleMap>, -) -> impl Iterator + 'a { +fn option_triple_map_flatten( + i: Option<&TripleMap>, +) -> impl Iterator + '_ { i.into_iter().flat_map(|spo| { spo.iter().flat_map(|(s, po)| { let s = *s; @@ -1072,7 +1072,7 @@ fn option_triple_map_flatten<'a, T: Copy>( }) } -fn quad_map_flatten<'a, T: Copy>(gspo: &'a QuadMap) -> impl Iterator + 'a { +fn quad_map_flatten(gspo: &QuadMap) -> impl Iterator + '_ { gspo.iter().flat_map(|(g, spo)| { let g = *g; spo.iter().flat_map(move |(s, po)| { diff --git a/python/src/model.rs b/python/src/model.rs index 1845abaa..9cfb6688 100644 --- a/python/src/model.rs +++ b/python/src/model.rs @@ -654,7 +654,7 @@ impl PyQuad { subject, predicate, object, - graph_name.unwrap_or_else(|| PyGraphName::DefaultGraph(PyDefaultGraph {})), + graph_name.unwrap_or(PyGraphName::DefaultGraph(PyDefaultGraph {})), ) .into() }