Improves slightly code style

pull/22/head
Tpt 5 years ago
parent 62e3d14984
commit 05a32f7d7a
  1. 18
      lib/src/model/literal.rs
  2. 1
      lib/src/repository.rs
  3. 3
      lib/src/sparql/eval.rs
  4. 14
      lib/src/sparql/mod.rs
  5. 2
      lib/src/sparql/xml_results.rs
  6. 2
      lib/src/store/memory.rs
  7. 2
      lib/src/store/rocksdb.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,
}
}

@ -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>,

@ -2503,6 +2503,7 @@ impl Accumulator for AvgAccumulator {
}
}
#[allow(clippy::option_option)]
struct MinAccumulator<'a, S: StoreConnection + 'a> {
eval: &'a SimpleEvaluator<S>,
min: Option<Option<EncodedTerm>>,
@ -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<S>,
max: Option<Option<EncodedTerm>>,
@ -2574,6 +2576,7 @@ impl Accumulator for SampleAccumulator {
}
}
#[allow(clippy::option_option)]
struct GroupConcatAccumulator<'a, S: StoreConnection + 'a> {
eval: &'a SimpleEvaluator<S>,
concat: Option<String>,

@ -63,9 +63,7 @@ impl<'a, S: StoreConnection + 'a> SimplePreparedQuery<S> {
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<S> {
}
}
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<S> {
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<S> {
}
}
QueryVariants::Describe {
algebra,
dataset: _,
base_iri,
algebra, base_iri, ..
} => {
let (plan, _) = PlanBuilder::build(dataset.encoder(), &algebra)?;
SimplePreparedQueryAction::Describe {

@ -78,7 +78,7 @@ pub fn write_xml_results<W: Write>(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()));

@ -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:
/// ```

@ -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:
/// ```

Loading…
Cancel
Save