Makes code more "Rust 2018" idiomatic

pull/10/head
Tpt 6 years ago
parent 610b75eaad
commit 1e0d803272
  1. 2
      lib/build.rs
  2. 10
      lib/src/lib.rs
  3. 2
      lib/src/model/blank_node.rs
  4. 4
      lib/src/model/literal.rs
  5. 2
      lib/src/model/named_node.rs
  6. 8
      lib/src/model/triple.rs
  7. 2
      lib/src/rio/ntriples/mod.rs
  8. 6
      lib/src/rio/turtle/mod.rs
  9. 2
      lib/src/rio/utils.rs
  10. 6
      lib/src/rio/xml.rs
  11. 44
      lib/src/sparql/algebra.rs
  12. 27
      lib/src/sparql/eval.rs
  13. 4
      lib/src/sparql/mod.rs
  14. 6
      lib/src/sparql/parser.rs
  15. 2
      lib/src/sparql/xml_results.rs
  16. 8
      lib/src/store/encoded.rs
  17. 6
      lib/src/store/memory.rs
  18. 7
      lib/tests/rdf_test_cases.rs
  19. 9
      lib/tests/sparql_test_cases.rs
  20. 3
      python/src/lib.rs
  21. 13
      server/src/main.rs

@ -1,4 +1,4 @@
extern crate peg; use peg;
fn main() { fn main() {
peg::cargo_build("src/rio/ntriples/ntriples_grammar.rustpeg"); peg::cargo_build("src/rio/ntriples/ntriples_grammar.rustpeg");

@ -37,22 +37,12 @@
clippy::unicode_not_nfc clippy::unicode_not_nfc
)] )]
extern crate byteorder;
extern crate chrono;
#[macro_use] #[macro_use]
extern crate failure; extern crate failure;
extern crate language_tags;
#[macro_use] #[macro_use]
extern crate lazy_static; extern crate lazy_static;
extern crate num_traits;
extern crate ordered_float;
extern crate quick_xml;
extern crate regex;
#[cfg(feature = "rocksdb")] #[cfg(feature = "rocksdb")]
extern crate rocksdb; extern crate rocksdb;
extern crate rust_decimal;
extern crate url;
extern crate uuid;
pub mod model; pub mod model;
pub mod rio; pub mod rio;

@ -24,7 +24,7 @@ impl BlankNode {
} }
impl fmt::Display for BlankNode { impl fmt::Display for BlankNode {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "_:{}", self.id.to_simple()) write!(f, "_:{}", self.id.to_simple())
} }
} }

@ -131,7 +131,7 @@ impl Literal {
} }
/// The literal [lexical form](https://www.w3.org/TR/rdf11-concepts/#dfn-lexical-form) /// The literal [lexical form](https://www.w3.org/TR/rdf11-concepts/#dfn-lexical-form)
pub fn value(&self) -> Cow<str> { pub fn value(&self) -> Cow<'_, str> {
match self.0 { match self.0 {
LiteralContent::SimpleLiteral(ref value) LiteralContent::SimpleLiteral(ref value)
| LiteralContent::String(ref value) | LiteralContent::String(ref value)
@ -348,7 +348,7 @@ impl Literal {
} }
impl fmt::Display for Literal { impl fmt::Display for Literal {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if self.is_plain() { if self.is_plain() {
self.language() self.language()
.map(|lang| write!(f, "\"{}\"@{}", self.value().escape(), lang)) .map(|lang| write!(f, "\"{}\"@{}", self.value().escape(), lang))

@ -27,7 +27,7 @@ pub struct NamedNode {
} }
impl fmt::Display for NamedNode { impl fmt::Display for NamedNode {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "<{}>", self.iri) write!(f, "<{}>", self.iri)
} }
} }

@ -27,7 +27,7 @@ impl NamedOrBlankNode {
} }
impl fmt::Display for NamedOrBlankNode { impl fmt::Display for NamedOrBlankNode {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
NamedOrBlankNode::NamedNode(node) => node.fmt(f), NamedOrBlankNode::NamedNode(node) => node.fmt(f),
NamedOrBlankNode::BlankNode(node) => node.fmt(f), NamedOrBlankNode::BlankNode(node) => node.fmt(f),
@ -91,7 +91,7 @@ impl Term {
} }
impl fmt::Display for Term { impl fmt::Display for Term {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Term::NamedNode(node) => node.fmt(f), Term::NamedNode(node) => node.fmt(f),
Term::BlankNode(node) => node.fmt(f), Term::BlankNode(node) => node.fmt(f),
@ -191,7 +191,7 @@ impl Triple {
} }
impl fmt::Display for Triple { impl fmt::Display for Triple {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{} {} {} .", self.subject, self.predicate, self.object) write!(f, "{} {} {} .", self.subject, self.predicate, self.object)
} }
} }
@ -263,7 +263,7 @@ impl Quad {
} }
impl fmt::Display for Quad { impl fmt::Display for Quad {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.graph_name { match self.graph_name {
Some(ref graph_name) => write!( Some(ref graph_name) => write!(
f, f,

@ -24,7 +24,7 @@ mod grammar {
); );
} }
pub fn unescape_echars(input: &str) -> Cow<str> { pub fn unescape_echars(input: &str) -> Cow<'_, str> {
unescape_characters(input, &UNESCAPE_CHARACTERS, &UNESCAPE_REPLACEMENT) unescape_characters(input, &UNESCAPE_CHARACTERS, &UNESCAPE_REPLACEMENT)
} }

@ -31,7 +31,7 @@ mod grammar {
} }
impl ParserState { impl ParserState {
fn url_parser(&self) -> ParseOptions { fn url_parser(&self) -> ParseOptions<'_> {
Url::options().base_url(self.base_uri.as_ref()) Url::options().base_url(self.base_uri.as_ref())
} }
} }
@ -71,7 +71,7 @@ mod grammar {
); );
} }
fn unescape_echars(input: &str) -> Cow<str> { fn unescape_echars(input: &str) -> Cow<'_, str> {
unescape_characters(input, &UNESCAPE_CHARACTERS, &UNESCAPE_REPLACEMENT) unescape_characters(input, &UNESCAPE_CHARACTERS, &UNESCAPE_REPLACEMENT)
} }
@ -92,7 +92,7 @@ mod grammar {
); );
} }
pub fn unescape_pn_local(input: &str) -> Cow<str> { pub fn unescape_pn_local(input: &str) -> Cow<'_, str> {
unescape_characters(input, &UNESCAPE_PN_CHARACTERS, &UNESCAPE_PN_REPLACEMENT) unescape_characters(input, &UNESCAPE_PN_CHARACTERS, &UNESCAPE_PN_REPLACEMENT)
} }
} }

@ -3,7 +3,7 @@ use std::borrow::Cow;
use std::char; use std::char;
use std::str::Chars; use std::str::Chars;
pub fn unescape_unicode_codepoints(input: &str) -> Cow<str> { pub fn unescape_unicode_codepoints(input: &str) -> Cow<'_, str> {
if needs_unescape_unicode_codepoints(input) { if needs_unescape_unicode_codepoints(input) {
UnescapeUnicodeCharIterator::new(input).collect() UnescapeUnicodeCharIterator::new(input).collect()
} else { } else {

@ -171,7 +171,7 @@ impl<R: BufRead> Iterator for RdfXmlIterator<R> {
} }
impl<R: BufRead> RdfXmlIterator<R> { impl<R: BufRead> RdfXmlIterator<R> {
fn parse_start_event(&mut self, event: &BytesStart) -> Result<()> { fn parse_start_event(&mut self, event: &BytesStart<'_>) -> Result<()> {
#[derive(PartialEq, Eq)] #[derive(PartialEq, Eq)]
enum RdfXmlParseType { enum RdfXmlParseType {
Default, Default,
@ -389,14 +389,14 @@ impl<R: BufRead> RdfXmlIterator<R> {
Ok(()) Ok(())
} }
fn parse_end_event(&mut self, _event: &BytesEnd) -> Result<()> { fn parse_end_event(&mut self, _event: &BytesEnd<'_>) -> Result<()> {
if let Some(current_state) = self.state.pop() { if let Some(current_state) = self.state.pop() {
self.end_state(current_state)?; self.end_state(current_state)?;
} }
Ok(()) Ok(())
} }
fn parse_text_event(&mut self, event: &BytesText) -> Result<()> { fn parse_text_event(&mut self, event: &BytesText<'_>) -> Result<()> {
self.object = Some(NodeOrText::Text(event.unescape_and_decode(&self.reader)?)); self.object = Some(NodeOrText::Text(event.unescape_and_decode(&self.reader)?));
Ok(()) Ok(())
} }

@ -37,7 +37,7 @@ impl Variable {
} }
impl fmt::Display for Variable { impl fmt::Display for Variable {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Variable::Variable { name } => write!(f, "?{}", name), Variable::Variable { name } => write!(f, "?{}", name),
Variable::BlankNode { id } => write!(f, "_:{}", id.to_simple()), Variable::BlankNode { id } => write!(f, "_:{}", id.to_simple()),
@ -67,7 +67,7 @@ pub enum NamedNodeOrVariable {
} }
impl fmt::Display for NamedNodeOrVariable { impl fmt::Display for NamedNodeOrVariable {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
NamedNodeOrVariable::NamedNode(node) => write!(f, "{}", node), NamedNodeOrVariable::NamedNode(node) => write!(f, "{}", node),
NamedNodeOrVariable::Variable(var) => write!(f, "{}", var), NamedNodeOrVariable::Variable(var) => write!(f, "{}", var),
@ -94,7 +94,7 @@ pub enum TermOrVariable {
} }
impl fmt::Display for TermOrVariable { impl fmt::Display for TermOrVariable {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
TermOrVariable::Term(term) => write!(f, "{}", term), TermOrVariable::Term(term) => write!(f, "{}", term),
TermOrVariable::Variable(var) => write!(f, "{}", var), TermOrVariable::Variable(var) => write!(f, "{}", var),
@ -242,7 +242,7 @@ impl TriplePattern {
} }
impl fmt::Display for TriplePattern { impl fmt::Display for TriplePattern {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{} {} {}", self.subject, self.predicate, self.object) write!(f, "{} {} {}", self.subject, self.predicate, self.object)
} }
} }
@ -260,7 +260,7 @@ pub enum PropertyPath {
} }
impl fmt::Display for PropertyPath { impl fmt::Display for PropertyPath {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
PropertyPath::PredicatePath(p) => write!(f, "link({})", p), PropertyPath::PredicatePath(p) => write!(f, "link({})", p),
PropertyPath::InversePath(p) => write!(f, "inv({})", p), PropertyPath::InversePath(p) => write!(f, "inv({})", p),
@ -284,7 +284,7 @@ impl fmt::Display for PropertyPath {
struct SparqlPropertyPath<'a>(&'a PropertyPath); struct SparqlPropertyPath<'a>(&'a PropertyPath);
impl<'a> fmt::Display for SparqlPropertyPath<'a> { impl<'a> fmt::Display for SparqlPropertyPath<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.0 { match self.0 {
PropertyPath::PredicatePath(p) => write!(f, "{}", p), PropertyPath::PredicatePath(p) => write!(f, "{}", p),
PropertyPath::InversePath(p) => write!(f, "^{}", SparqlPropertyPath(&*p)), PropertyPath::InversePath(p) => write!(f, "^{}", SparqlPropertyPath(&*p)),
@ -329,7 +329,7 @@ pub struct PathPattern {
} }
impl fmt::Display for PathPattern { impl fmt::Display for PathPattern {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Path({} {} {})", self.subject, self.path, self.object) write!(f, "Path({} {} {})", self.subject, self.path, self.object)
} }
} }
@ -351,7 +351,7 @@ impl PathPattern {
struct SparqlPathPattern<'a>(&'a PathPattern); struct SparqlPathPattern<'a>(&'a PathPattern);
impl<'a> fmt::Display for SparqlPathPattern<'a> { impl<'a> fmt::Display for SparqlPathPattern<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!( write!(
f, f,
"{} {} {}", "{} {} {}",
@ -369,7 +369,7 @@ pub enum TripleOrPathPattern {
} }
impl<'a> fmt::Display for TripleOrPathPattern { impl<'a> fmt::Display for TripleOrPathPattern {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
TripleOrPathPattern::Triple(tp) => write!(f, "{}", tp), TripleOrPathPattern::Triple(tp) => write!(f, "{}", tp),
TripleOrPathPattern::Path(ppp) => write!(f, "{}", ppp), TripleOrPathPattern::Path(ppp) => write!(f, "{}", ppp),
@ -392,7 +392,7 @@ impl From<PathPattern> for TripleOrPathPattern {
struct SparqlTripleOrPathPattern<'a>(&'a TripleOrPathPattern); struct SparqlTripleOrPathPattern<'a>(&'a TripleOrPathPattern);
impl<'a> fmt::Display for SparqlTripleOrPathPattern<'a> { impl<'a> fmt::Display for SparqlTripleOrPathPattern<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.0 { match self.0 {
TripleOrPathPattern::Triple(tp) => write!(f, "{}", tp), TripleOrPathPattern::Triple(tp) => write!(f, "{}", tp),
TripleOrPathPattern::Path(ppp) => write!(f, "{}", SparqlPathPattern(&ppp)), TripleOrPathPattern::Path(ppp) => write!(f, "{}", SparqlPathPattern(&ppp)),
@ -479,7 +479,7 @@ pub enum Expression {
} }
impl fmt::Display for Expression { impl fmt::Display for Expression {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Expression::Constant(t) => write!(f, "{}", t), Expression::Constant(t) => write!(f, "{}", t),
Expression::Or(a, b) => write!(f, "({} || {})", a, b), Expression::Or(a, b) => write!(f, "({} || {})", a, b),
@ -629,7 +629,7 @@ impl From<Variable> for Expression {
struct SparqlExpression<'a>(&'a Expression); struct SparqlExpression<'a>(&'a Expression);
impl<'a> fmt::Display for SparqlExpression<'a> { impl<'a> fmt::Display for SparqlExpression<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.0 { match self.0 {
Expression::Constant(t) => write!(f, "{}", t), Expression::Constant(t) => write!(f, "{}", t),
Expression::Or(a, b) => write!( Expression::Or(a, b) => write!(
@ -917,7 +917,7 @@ pub enum GraphPattern {
} }
impl fmt::Display for GraphPattern { impl fmt::Display for GraphPattern {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
GraphPattern::BGP(p) => write!( GraphPattern::BGP(p) => write!(
f, f,
@ -1082,7 +1082,7 @@ fn adds_if_has_name<'a>(vars: &mut BTreeSet<&'a Variable>, var: &'a Variable) {
struct SparqlGraphPattern<'a>(&'a GraphPattern); struct SparqlGraphPattern<'a>(&'a GraphPattern);
impl<'a> fmt::Display for SparqlGraphPattern<'a> { impl<'a> fmt::Display for SparqlGraphPattern<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.0 { match self.0 {
GraphPattern::BGP(p) => { GraphPattern::BGP(p) => {
for pattern in p { for pattern in p {
@ -1192,7 +1192,7 @@ struct SparqlGraphRootPattern<'a> {
} }
impl<'a> fmt::Display for SparqlGraphRootPattern<'a> { impl<'a> fmt::Display for SparqlGraphRootPattern<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut distinct = false; let mut distinct = false;
let mut reduced = false; let mut reduced = false;
let mut order = None; let mut order = None;
@ -1267,7 +1267,7 @@ impl<'a> fmt::Display for SparqlGraphRootPattern<'a> {
pub struct GroupPattern(pub Vec<Expression>, pub Box<GraphPattern>); pub struct GroupPattern(pub Vec<Expression>, pub Box<GraphPattern>);
impl fmt::Display for GroupPattern { impl fmt::Display for GroupPattern {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!( write!(
f, f,
"Group(({}), {})", "Group(({}), {})",
@ -1304,7 +1304,7 @@ pub enum Aggregation {
} }
impl fmt::Display for Aggregation { impl fmt::Display for Aggregation {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Aggregation::Count(e, distinct) => { Aggregation::Count(e, distinct) => {
if *distinct { if *distinct {
@ -1388,7 +1388,7 @@ impl fmt::Display for Aggregation {
struct SparqlAggregation<'a>(&'a Aggregation); struct SparqlAggregation<'a>(&'a Aggregation);
impl<'a> fmt::Display for SparqlAggregation<'a> { impl<'a> fmt::Display for SparqlAggregation<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.0 { match self.0 {
Aggregation::Count(e, distinct) => { Aggregation::Count(e, distinct) => {
if *distinct { if *distinct {
@ -1472,7 +1472,7 @@ pub enum OrderComparator {
} }
impl fmt::Display for OrderComparator { impl fmt::Display for OrderComparator {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
OrderComparator::Asc(e) => write!(f, "ASC({})", e), OrderComparator::Asc(e) => write!(f, "ASC({})", e),
OrderComparator::Desc(e) => write!(f, "DESC({})", e), OrderComparator::Desc(e) => write!(f, "DESC({})", e),
@ -1489,7 +1489,7 @@ impl From<Expression> for OrderComparator {
struct SparqlOrderComparator<'a>(&'a OrderComparator); struct SparqlOrderComparator<'a>(&'a OrderComparator);
impl<'a> fmt::Display for SparqlOrderComparator<'a> { impl<'a> fmt::Display for SparqlOrderComparator<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.0 { match self.0 {
OrderComparator::Asc(e) => write!(f, "ASC({})", SparqlExpression(e)), OrderComparator::Asc(e) => write!(f, "ASC({})", SparqlExpression(e)),
OrderComparator::Desc(e) => write!(f, "DESC({})", SparqlExpression(e)), OrderComparator::Desc(e) => write!(f, "DESC({})", SparqlExpression(e)),
@ -1530,7 +1530,7 @@ impl Add for DatasetSpec {
} }
impl fmt::Display for DatasetSpec { impl fmt::Display for DatasetSpec {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
for g in &self.default { for g in &self.default {
write!(f, "FROM {} ", g)?; write!(f, "FROM {} ", g)?;
} }
@ -1567,7 +1567,7 @@ pub enum Query {
} }
impl fmt::Display for Query { impl fmt::Display for Query {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
Query::Select { dataset, algebra } => write!( Query::Select { dataset, algebra } => write!(
f, f,

@ -156,15 +156,24 @@ impl<S: EncodedQuadsStore> SimpleEvaluator<S> {
})) }))
} }
} }
let iter: EncodedTuplesIterator = Box::new(iter.map(move |quad| { let iter: EncodedTuplesIterator<'_> =
let quad = quad?; Box::new(iter.map(move |quad| {
let mut new_tuple = tuple.clone(); let quad = quad?;
put_pattern_value(&subject, quad.subject, &mut new_tuple); let mut new_tuple = tuple.clone();
put_pattern_value(&predicate, quad.predicate, &mut new_tuple); put_pattern_value(&subject, quad.subject, &mut new_tuple);
put_pattern_value(&object, quad.object, &mut new_tuple); put_pattern_value(
put_pattern_value(&graph_name, quad.graph_name, &mut new_tuple); &predicate,
Ok(new_tuple) quad.predicate,
})); &mut new_tuple,
);
put_pattern_value(&object, quad.object, &mut new_tuple);
put_pattern_value(
&graph_name,
quad.graph_name,
&mut new_tuple,
);
Ok(new_tuple)
}));
iter iter
} }
Err(error) => Box::new(once(Err(error))), Err(error) => Box::new(once(Err(error))),

@ -58,7 +58,7 @@ pub trait SparqlDataset: Dataset {
/// A prepared [SPARQL 1.1](https://www.w3.org/TR/sparql11-query/) query /// A prepared [SPARQL 1.1](https://www.w3.org/TR/sparql11-query/) query
pub trait PreparedQuery { pub trait PreparedQuery {
/// Evaluates the query and returns its results /// Evaluates the query and returns its results
fn exec(&self) -> Result<QueryResult>; fn exec(&self) -> Result<QueryResult<'_>>;
} }
impl<S: EncodedQuadsStore> SparqlDataset for StoreDataset<S> { impl<S: EncodedQuadsStore> SparqlDataset for StoreDataset<S> {
@ -142,7 +142,7 @@ enum SimplePreparedQueryOptions<S: EncodedQuadsStore> {
} }
impl<S: EncodedQuadsStore> PreparedQuery for SimplePreparedQuery<S> { impl<S: EncodedQuadsStore> PreparedQuery for SimplePreparedQuery<S> {
fn exec(&self) -> Result<QueryResult> { fn exec(&self) -> Result<QueryResult<'_>> {
match &self.0 { match &self.0 {
SimplePreparedQueryOptions::Select { SimplePreparedQueryOptions::Select {
plan, plan,

@ -301,7 +301,7 @@ mod grammar {
} }
impl ParserState { impl ParserState {
fn url_parser(&self) -> ParseOptions { fn url_parser(&self) -> ParseOptions<'_> {
Url::options().base_url(self.base_uri.as_ref()) Url::options().base_url(self.base_uri.as_ref())
} }
@ -325,7 +325,7 @@ mod grammar {
); );
} }
fn unescape_echars(input: &str) -> Cow<str> { fn unescape_echars(input: &str) -> Cow<'_, str> {
unescape_characters(input, &UNESCAPE_CHARACTERS, &UNESCAPE_REPLACEMENT) unescape_characters(input, &UNESCAPE_CHARACTERS, &UNESCAPE_REPLACEMENT)
} }
@ -346,7 +346,7 @@ mod grammar {
); );
} }
pub fn unescape_pn_local(input: &str) -> Cow<str> { pub fn unescape_pn_local(input: &str) -> Cow<'_, str> {
unescape_characters(input, &UNESCAPE_PN_CHARACTERS, &UNESCAPE_PN_REPLACEMENT) unescape_characters(input, &UNESCAPE_PN_CHARACTERS, &UNESCAPE_PN_REPLACEMENT)
} }

@ -18,7 +18,7 @@ use std::io::Write;
use std::iter::empty; use std::iter::empty;
use std::str::FromStr; use std::str::FromStr;
pub fn write_xml_results<W: Write>(results: QueryResult, sink: W) -> Result<W> { pub fn write_xml_results<W: Write>(results: QueryResult<'_>, sink: W) -> Result<W> {
let mut writer = Writer::new(sink); let mut writer = Writer::new(sink);
match results { match results {
QueryResult::Boolean(value) => { QueryResult::Boolean(value) => {

@ -361,7 +361,7 @@ impl<S: EncodedQuadsStore> Dataset for StoreDataset<S> {
} }
impl<S: EncodedQuadsStore> fmt::Display for StoreDataset<S> { impl<S: EncodedQuadsStore> fmt::Display for StoreDataset<S> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
for quad in self.iter().map_err(|_| fmt::Error)? { for quad in self.iter().map_err(|_| fmt::Error)? {
writeln!(fmt, "{}", quad.map_err(|_| fmt::Error)?)?; writeln!(fmt, "{}", quad.map_err(|_| fmt::Error)?)?;
} }
@ -547,7 +547,7 @@ impl<S: EncodedQuadsStore> NamedGraph for StoreNamedGraph<S> {
} }
impl<S: EncodedQuadsStore> fmt::Display for StoreNamedGraph<S> { impl<S: EncodedQuadsStore> fmt::Display for StoreNamedGraph<S> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
for triple in self.iter().map_err(|_| fmt::Error)? { for triple in self.iter().map_err(|_| fmt::Error)? {
writeln!(fmt, "{}", triple.map_err(|_| fmt::Error)?)?; writeln!(fmt, "{}", triple.map_err(|_| fmt::Error)?)?;
} }
@ -702,7 +702,7 @@ impl<S: EncodedQuadsStore> Graph for StoreDefaultGraph<S> {
} }
impl<S: EncodedQuadsStore> fmt::Display for StoreDefaultGraph<S> { impl<S: EncodedQuadsStore> fmt::Display for StoreDefaultGraph<S> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
for triple in self.iter().map_err(|_| fmt::Error)? { for triple in self.iter().map_err(|_| fmt::Error)? {
writeln!(fmt, "{}", triple.map_err(|_| fmt::Error)?)?; writeln!(fmt, "{}", triple.map_err(|_| fmt::Error)?)?;
} }
@ -867,7 +867,7 @@ impl<S: EncodedQuadsStore> Graph for StoreUnionGraph<S> {
} }
impl<S: EncodedQuadsStore> fmt::Display for StoreUnionGraph<S> { impl<S: EncodedQuadsStore> fmt::Display for StoreUnionGraph<S> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
for triple in self.iter().map_err(|_| fmt::Error)? { for triple in self.iter().map_err(|_| fmt::Error)? {
writeln!(fmt, "{}", triple.map_err(|_| fmt::Error)?)?; writeln!(fmt, "{}", triple.map_err(|_| fmt::Error)?)?;
} }

@ -481,13 +481,15 @@ impl EncodedQuadsStore for MemoryStore {
} }
impl MemoryStore { impl MemoryStore {
fn graph_indexes(&self) -> Result<RwLockReadGuard<BTreeMap<EncodedTerm, MemoryGraphIndexes>>> { fn graph_indexes(
&self,
) -> Result<RwLockReadGuard<'_, BTreeMap<EncodedTerm, MemoryGraphIndexes>>> {
Ok(self.graph_indexes.read().map_err(MutexPoisonError::from)?) Ok(self.graph_indexes.read().map_err(MutexPoisonError::from)?)
} }
fn graph_indexes_mut( fn graph_indexes_mut(
&self, &self,
) -> Result<RwLockWriteGuard<BTreeMap<EncodedTerm, MemoryGraphIndexes>>> { ) -> Result<RwLockWriteGuard<'_, BTreeMap<EncodedTerm, MemoryGraphIndexes>>> {
Ok(self.graph_indexes.write().map_err(MutexPoisonError::from)?) Ok(self.graph_indexes.write().map_err(MutexPoisonError::from)?)
} }
} }

@ -2,9 +2,6 @@
#[macro_use] #[macro_use]
extern crate lazy_static; extern crate lazy_static;
extern crate reqwest;
extern crate rudf;
extern crate url;
#[macro_use] #[macro_use]
extern crate failure; extern crate failure;
@ -232,7 +229,7 @@ pub struct Test {
} }
impl fmt::Display for Test { impl fmt::Display for Test {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.kind)?; write!(f, "{}", self.kind)?;
for name in &self.name { for name in &self.name {
write!(f, " named \"{}\"", name)?; write!(f, " named \"{}\"", name)?;
@ -408,7 +405,7 @@ impl<'a> Iterator for TestManifest<'a> {
} }
} }
pub struct RdfListIterator<'a, G: 'a + Graph> { pub struct RdfListIterator<'a, G: Graph> {
graph: &'a G, graph: &'a G,
current_node: Option<NamedOrBlankNode>, current_node: Option<NamedOrBlankNode>,
} }

@ -1,9 +1,6 @@
///! Integration tests based on [SPARQL 1.1 Test Cases](https://www.w3.org/2009/sparql/docs/tests/README.html) ///! Integration tests based on [SPARQL 1.1 Test Cases](https://www.w3.org/2009/sparql/docs/tests/README.html)
#[macro_use] #[macro_use]
extern crate lazy_static; extern crate lazy_static;
extern crate reqwest;
extern crate rudf;
extern crate url;
#[macro_use] #[macro_use]
extern crate failure; extern crate failure;
@ -353,7 +350,7 @@ mod rs {
} }
} }
fn to_graph(result: QueryResult, with_order: bool) -> Result<MemoryGraph> { fn to_graph(result: QueryResult<'_>, with_order: bool) -> Result<MemoryGraph> {
match result { match result {
QueryResult::Graph(graph) => graph.collect(), QueryResult::Graph(graph) => graph.collect(),
QueryResult::Boolean(value) => { QueryResult::Boolean(value) => {
@ -440,7 +437,7 @@ pub struct Test {
} }
impl fmt::Display for Test { impl fmt::Display for Test {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.kind)?; write!(f, "{}", self.kind)?;
for name in &self.name { for name in &self.name {
write!(f, " named \"{}\"", name)?; write!(f, " named \"{}\"", name)?;
@ -679,7 +676,7 @@ impl<'a> Iterator for TestManifest<'a> {
} }
} }
pub struct RdfListIterator<'a, G: 'a + Graph> { pub struct RdfListIterator<'a, G: Graph> {
graph: &'a G, graph: &'a G,
current_node: Option<NamedOrBlankNode>, current_node: Option<NamedOrBlankNode>,
} }

@ -2,7 +2,6 @@
#[macro_use] #[macro_use]
extern crate cpython; extern crate cpython;
extern crate rudf;
use cpython::exc::ValueError; use cpython::exc::ValueError;
use cpython::CompareOp; use cpython::CompareOp;
@ -26,7 +25,7 @@ py_module_initializer!(rudf, initrudf, PyInit_rudf, |py, m| {
Ok(()) Ok(())
}); });
fn new_value_error(py: Python, error: &Error) -> PyErr { fn new_value_error(py: Python<'_>, error: &Error) -> PyErr {
PyErr::new::<ValueError, _>(py, error.to_string()) PyErr::new::<ValueError, _>(py, error.to_string())
} }

@ -1,21 +1,16 @@
extern crate clap;
#[macro_use] #[macro_use]
extern crate failure; extern crate failure;
extern crate futures; use gotham;
extern crate gotham;
#[macro_use] #[macro_use]
extern crate gotham_derive; extern crate gotham_derive;
extern crate hyper; use hyper;
#[macro_use] #[macro_use]
extern crate lazy_static; extern crate lazy_static;
extern crate mime; use mime;
extern crate rudf;
extern crate serde;
#[macro_use] #[macro_use]
extern crate serde_derive; extern crate serde_derive;
#[macro_use] #[macro_use]
extern crate tera; extern crate tera;
extern crate url;
use clap::App; use clap::App;
use clap::Arg; use clap::Arg;
@ -105,7 +100,7 @@ pub fn main() -> Result<(), failure::Error> {
fn main_with_dataset<D: SparqlDataset + Send + Sync + RefUnwindSafe + 'static>( fn main_with_dataset<D: SparqlDataset + Send + Sync + RefUnwindSafe + 'static>(
dataset: Arc<D>, dataset: Arc<D>,
matches: &ArgMatches, matches: &ArgMatches<'_>,
) -> Result<(), failure::Error> { ) -> Result<(), failure::Error> {
if let Some(nt_file) = matches.value_of("ntriples") { if let Some(nt_file) = matches.value_of("ntriples") {
println!("Loading NTriples file {}", nt_file); println!("Loading NTriples file {}", nt_file);

Loading…
Cancel
Save