From 05a32f7d7aa97d332bc273c6e3df477743a811e8 Mon Sep 17 00:00:00 2001 From: Tpt Date: Mon, 18 Nov 2019 20:33:47 +0100 Subject: [PATCH] Improves slightly code style --- lib/src/model/literal.rs | 18 +++++++++--------- lib/src/repository.rs | 1 + lib/src/sparql/eval.rs | 3 +++ lib/src/sparql/mod.rs | 14 ++++---------- lib/src/sparql/xml_results.rs | 2 +- lib/src/store/memory.rs | 2 +- lib/src/store/rocksdb.rs | 2 +- 7 files changed, 20 insertions(+), 22 deletions(-) diff --git a/lib/src/model/literal.rs b/lib/src/model/literal.rs index a5b2533d..760a4439 100644 --- a/lib/src/model/literal.rs +++ b/lib/src/model/literal.rs @@ -72,10 +72,10 @@ impl Literal { /// The literal [lexical form](https://www.w3.org/TR/rdf11-concepts/#dfn-lexical-form) pub fn value(&self) -> &str { - match self.0 { - LiteralContent::String(ref value) - | LiteralContent::LanguageTaggedString { ref value, .. } - | LiteralContent::TypedLiteral { ref value, .. } => value, + match &self.0 { + LiteralContent::String(value) + | LiteralContent::LanguageTaggedString { value, .. } + | LiteralContent::TypedLiteral { value, .. } => value, } } @@ -83,9 +83,9 @@ impl Literal { /// /// Language tags are defined by the [BCP47](https://tools.ietf.org/html/bcp47). /// They are normalized to lowercase by this implementation. - pub fn language(&self) -> Option<&String> { - match self.0 { - LiteralContent::LanguageTaggedString { ref language, .. } => Some(language), + pub fn language(&self) -> Option<&str> { + match &self.0 { + LiteralContent::LanguageTaggedString { language, .. } => Some(language), _ => None, } } @@ -95,10 +95,10 @@ impl Literal { /// The datatype of [language-tagged string](https://www.w3.org/TR/rdf11-concepts/#dfn-language-tagged-string) is always [rdf:langString](http://www.w3.org/1999/02/22-rdf-syntax-ns#langString). /// The datatype of [simple literals](https://www.w3.org/TR/rdf11-concepts/#dfn-simple-literal) is [xsd:string](http://www.w3.org/2001/XMLSchema#string). pub fn datatype(&self) -> &NamedNode { - match self.0 { + match &self.0 { LiteralContent::String(_) => &xsd::STRING, LiteralContent::LanguageTaggedString { .. } => &rdf::LANG_STRING, - LiteralContent::TypedLiteral { ref datatype, .. } => datatype, + LiteralContent::TypedLiteral { datatype, .. } => datatype, } } diff --git a/lib/src/repository.rs b/lib/src/repository.rs index 8f31eba1..81940530 100644 --- a/lib/src/repository.rs +++ b/lib/src/repository.rs @@ -113,6 +113,7 @@ pub trait RepositoryConnection: Clone { /// assert_eq!(vec![quad], results?); /// # Result::Ok(()) /// ``` + #[allow(clippy::option_option)] fn quads_for_pattern<'a>( &'a self, subject: Option<&NamedOrBlankNode>, diff --git a/lib/src/sparql/eval.rs b/lib/src/sparql/eval.rs index 6ca2e14f..eccd165c 100644 --- a/lib/src/sparql/eval.rs +++ b/lib/src/sparql/eval.rs @@ -2503,6 +2503,7 @@ impl Accumulator for AvgAccumulator { } } +#[allow(clippy::option_option)] struct MinAccumulator<'a, S: StoreConnection + 'a> { eval: &'a SimpleEvaluator, min: Option>, @@ -2530,6 +2531,7 @@ impl<'a, S: StoreConnection + 'a> Accumulator for MinAccumulator<'a, S> { } } +#[allow(clippy::option_option)] struct MaxAccumulator<'a, S: StoreConnection + 'a> { eval: &'a SimpleEvaluator, max: Option>, @@ -2574,6 +2576,7 @@ impl Accumulator for SampleAccumulator { } } +#[allow(clippy::option_option)] struct GroupConcatAccumulator<'a, S: StoreConnection + 'a> { eval: &'a SimpleEvaluator, concat: Option, diff --git a/lib/src/sparql/mod.rs b/lib/src/sparql/mod.rs index deb5d347..9951dad4 100644 --- a/lib/src/sparql/mod.rs +++ b/lib/src/sparql/mod.rs @@ -63,9 +63,7 @@ impl<'a, S: StoreConnection + 'a> SimplePreparedQuery { let dataset = DatasetView::new(connection, options.default_graph_as_union); Ok(Self(match read_sparql_query(query, options.base_iri)? { QueryVariants::Select { - algebra, - dataset: _, - base_iri, + algebra, base_iri, .. } => { let (plan, variables) = PlanBuilder::build(dataset.encoder(), &algebra)?; SimplePreparedQueryAction::Select { @@ -75,9 +73,7 @@ impl<'a, S: StoreConnection + 'a> SimplePreparedQuery { } } QueryVariants::Ask { - algebra, - dataset: _, - base_iri, + algebra, base_iri, .. } => { let (plan, _) = PlanBuilder::build(dataset.encoder(), &algebra)?; SimplePreparedQueryAction::Ask { @@ -88,8 +84,8 @@ impl<'a, S: StoreConnection + 'a> SimplePreparedQuery { QueryVariants::Construct { construct, algebra, - dataset: _, base_iri, + .. } => { let (plan, variables) = PlanBuilder::build(dataset.encoder(), &algebra)?; SimplePreparedQueryAction::Construct { @@ -103,9 +99,7 @@ impl<'a, S: StoreConnection + 'a> SimplePreparedQuery { } } QueryVariants::Describe { - algebra, - dataset: _, - base_iri, + algebra, base_iri, .. } => { let (plan, _) = PlanBuilder::build(dataset.encoder(), &algebra)?; SimplePreparedQueryAction::Describe { diff --git a/lib/src/sparql/xml_results.rs b/lib/src/sparql/xml_results.rs index 225caa55..c0104033 100644 --- a/lib/src/sparql/xml_results.rs +++ b/lib/src/sparql/xml_results.rs @@ -78,7 +78,7 @@ pub fn write_xml_results(results: QueryResult<'_>, sink: W) -> Result< Term::Literal(literal) => { let mut literal_tag = BytesStart::borrowed_name(b"literal"); if let Some(language) = literal.language() { - literal_tag.push_attribute(("xml:lang", language.as_str())); + literal_tag.push_attribute(("xml:lang", language)); } else if !literal.is_plain() { literal_tag .push_attribute(("datatype", literal.datatype().as_str())); diff --git a/lib/src/store/memory.rs b/lib/src/store/memory.rs index e3ab2688..3ba378d8 100644 --- a/lib/src/store/memory.rs +++ b/lib/src/store/memory.rs @@ -7,7 +7,7 @@ use std::iter::{empty, once}; use std::sync::{PoisonError, RwLock, RwLockReadGuard, RwLockWriteGuard}; /// Memory based implementation of the `Repository` trait. -/// They are cheap to build using the `MemoryRepository::default()` method. +/// It is cheap to build using the `MemoryRepository::default()` method. /// /// Usage example: /// ``` diff --git a/lib/src/store/rocksdb.rs b/lib/src/store/rocksdb.rs index 3bbee60b..fa4765f5 100644 --- a/lib/src/store/rocksdb.rs +++ b/lib/src/store/rocksdb.rs @@ -11,7 +11,7 @@ use std::str; /// `Repository` implementation based on the [RocksDB](https://rocksdb.org/) key-value store /// -/// To use it, the `"rocksdb"` feature need to be activated. +/// To use it, the `"rocksdb"` feature needs to be activated. /// /// Usage example: /// ```