Upgrades fmt to rust 1.29 and fixes some clippy warnings

pull/10/head
Tpt 6 years ago
parent cec5075777
commit 472a9292b3
  1. 28
      src/model/triple.rs
  2. 2
      src/rio/turtle/mod.rs
  3. 2
      src/rio/turtle/turtle_grammar.rustpeg
  4. 21
      src/sparql/algebra.rs
  5. 23
      src/sparql/parser.rs
  6. 28
      src/sparql/sparql_grammar.rustpeg
  7. 2
      src/store/isomorphism.rs
  8. 10
      src/store/memory.rs
  9. 4
      src/store/numeric_encoder.rs
  10. 18
      src/store/rocksdb.rs
  11. 11
      src/store/store.rs
  12. 4
      src/utils.rs
  13. 39
      tests/rdf_test_cases.rs

@ -180,27 +180,27 @@ impl fmt::Display for Triple {
impl TripleLike for Triple { impl TripleLike for Triple {
fn subject(&self) -> &NamedOrBlankNode { fn subject(&self) -> &NamedOrBlankNode {
return &self.subject; &self.subject
} }
fn subject_owned(self) -> NamedOrBlankNode { fn subject_owned(self) -> NamedOrBlankNode {
return self.subject; self.subject
} }
fn predicate(&self) -> &NamedNode { fn predicate(&self) -> &NamedNode {
return &self.predicate; &self.predicate
} }
fn predicate_owned(self) -> NamedNode { fn predicate_owned(self) -> NamedNode {
return self.predicate; self.predicate
} }
fn object(&self) -> &Term { fn object(&self) -> &Term {
return &self.object; &self.object
} }
fn object_owned(self) -> Term { fn object_owned(self) -> Term {
return self.object; self.object
} }
} }
@ -254,36 +254,36 @@ impl fmt::Display for Quad {
impl TripleLike for Quad { impl TripleLike for Quad {
fn subject(&self) -> &NamedOrBlankNode { fn subject(&self) -> &NamedOrBlankNode {
return &self.subject; &self.subject
} }
fn subject_owned(self) -> NamedOrBlankNode { fn subject_owned(self) -> NamedOrBlankNode {
return self.subject; self.subject
} }
fn predicate(&self) -> &NamedNode { fn predicate(&self) -> &NamedNode {
return &self.predicate; &self.predicate
} }
fn predicate_owned(self) -> NamedNode { fn predicate_owned(self) -> NamedNode {
return self.predicate; self.predicate
} }
fn object(&self) -> &Term { fn object(&self) -> &Term {
return &self.object; &self.object
} }
fn object_owned(self) -> Term { fn object_owned(self) -> Term {
return self.object; self.object
} }
} }
impl QuadLike for Quad { impl QuadLike for Quad {
fn graph_name(&self) -> &Option<NamedOrBlankNode> { fn graph_name(&self) -> &Option<NamedOrBlankNode> {
return &self.graph_name; &self.graph_name
} }
fn graph_name_owned(self) -> Option<NamedOrBlankNode> { fn graph_name_owned(self) -> Option<NamedOrBlankNode> {
return self.graph_name; self.graph_name
} }
} }

@ -20,7 +20,7 @@ mod grammar {
} }
impl ParserState { impl ParserState {
fn url_parser<'a>(&'a self) -> ParseOptions<'a> { fn url_parser(&self) -> ParseOptions {
Url::options().base_url(self.base_uri.as_ref()) Url::options().base_url(self.base_uri.as_ref())
} }
} }

@ -46,7 +46,7 @@ sparqlBase -> () = "BASE"i _ i:IRIREF {?
//[6s] //[6s]
sparqlPrefix -> () = "PREFIX"i _ ns:PNAME_NS _ i:IRIREF { sparqlPrefix -> () = "PREFIX"i _ ns:PNAME_NS _ i:IRIREF {
state.namespaces.insert(ns.into(), i.into()); state.namespaces.insert(ns.into(), i);
} }
//[6] //[6]

@ -76,7 +76,7 @@ impl<'a> fmt::Display for SparqlPropertyPath<'a> {
impl From<NamedNode> for PropertyPath { impl From<NamedNode> for PropertyPath {
fn from(p: NamedNode) -> Self { fn from(p: NamedNode) -> Self {
PropertyPath::PredicatePath(p.into()) PropertyPath::PredicatePath(p)
} }
} }
@ -502,8 +502,7 @@ impl<'a> fmt::Display for SparqlExpression<'a> {
SparqlExpression(&*b), SparqlExpression(&*b),
SparqlExpression(cv) SparqlExpression(cv)
) )
}) }).unwrap_or_else(|| {
.unwrap_or_else(|| {
write!( write!(
f, f,
"SUBSTR({}, {})", "SUBSTR({}, {})",
@ -523,8 +522,7 @@ impl<'a> fmt::Display for SparqlExpression<'a> {
SparqlExpression(&*c), SparqlExpression(&*c),
dv dv
) )
}) }).unwrap_or_else(|| {
.unwrap_or_else(|| {
write!( write!(
f, f,
"REPLACE({}, {}, {})", "REPLACE({}, {}, {})",
@ -634,8 +632,7 @@ impl<'a> fmt::Display for SparqlExpression<'a> {
SparqlExpression(&*b), SparqlExpression(&*b),
cv cv
) )
}) }).unwrap_or_else(|| {
.unwrap_or_else(|| {
write!( write!(
f, f,
"REGEX({}, {})", "REGEX({}, {})",
@ -729,7 +726,7 @@ impl From<ListPattern> for MultiSetPattern {
} }
impl MultiSetPattern { impl MultiSetPattern {
pub fn visible_variables<'a>(&'a self) -> BTreeSet<&'a Variable> { pub fn visible_variables(&self) -> BTreeSet<&Variable> {
let mut vars = BTreeSet::default(); let mut vars = BTreeSet::default();
self.add_visible_variables(&mut vars); self.add_visible_variables(&mut vars);
vars vars
@ -1102,8 +1099,7 @@ impl<'a> fmt::Display for SparqlListPattern<'a> {
start, start,
length length
) )
}) }).unwrap_or_else(|| {
.unwrap_or_else(|| {
write!( write!(
f, f,
"{} LIMIT {}", "{} LIMIT {}",
@ -1118,7 +1114,7 @@ impl<'a> fmt::Display for SparqlListPattern<'a> {
} }
} }
fn build_sparql_select_arguments(args: &Vec<Variable>) -> String { fn build_sparql_select_arguments(args: &[Variable]) -> String {
if args.is_empty() { if args.is_empty() {
"*".to_owned() "*".to_owned()
} else { } else {
@ -1263,8 +1259,7 @@ impl<'a> fmt::Display for SparqlAggregation<'a> {
SparqlExpression(e), SparqlExpression(e),
s.escape() s.escape()
) )
}) }).unwrap_or_else(|| write!(f, "GROUP_CONCAT({})", SparqlExpression(e)))
.unwrap_or_else(|| write!(f, "GROUP_CONCAT({})", SparqlExpression(e)))
}, },
} }
} }

@ -228,7 +228,7 @@ mod grammar {
} }
} }
None => { None => {
pv.extend(p.visible_variables().into_iter().map(|v| v.clone())) //TODO: is it really useful to do a projection? pv.extend(p.visible_variables().into_iter().cloned()) //TODO: is it really useful to do a projection?
} }
} }
let mut m = ListPattern::from(p); let mut m = ListPattern::from(p);
@ -266,19 +266,16 @@ mod grammar {
} }
impl ParserState { impl ParserState {
fn url_parser<'a>(&'a self) -> ParseOptions<'a> { fn url_parser(&self) -> ParseOptions {
Url::options().base_url(self.base_uri.as_ref()) Url::options().base_url(self.base_uri.as_ref())
} }
fn new_aggregation(&mut self, agg: Aggregation) -> Variable { fn new_aggregation(&mut self, agg: Aggregation) -> Variable {
self.aggregations self.aggregations.get(&agg).cloned().unwrap_or_else(|| {
.get(&agg) let new_var = Variable::default();
.map(|v| v.clone()) self.aggregations.insert(agg, new_var.clone());
.unwrap_or_else(|| { new_var
let new_var = Variable::default(); })
self.aggregations.insert(agg, new_var.clone());
new_var
})
} }
} }
@ -314,11 +311,11 @@ pub use self::grammar::read_sparql_query;
fn needs_unescape_unicode_codepoints(input: &str) -> bool { fn needs_unescape_unicode_codepoints(input: &str) -> bool {
let bytes = input.as_bytes(); let bytes = input.as_bytes();
for i in 1..bytes.len() { for i in 1..bytes.len() {
if (bytes[i] == ('u' as u8) || bytes[i] == ('U' as u8)) && bytes[i - 1] == ('/' as u8) { if (bytes[i] == b'u' || bytes[i] == b'U') && bytes[i - 1] == b'/' {
return true; return true;
} }
} }
return false; false
} }
struct UnescapeUnicodeCharIterator<'a> { struct UnescapeUnicodeCharIterator<'a> {
@ -393,7 +390,7 @@ impl<'a> Iterator for UnescapeUnicodeCharIterator<'a> {
} }
} }
fn unescape_unicode_codepoints<'a>(input: Cow<'a, str>) -> Cow<'a, str> { fn unescape_unicode_codepoints(input: Cow<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 {

@ -257,7 +257,9 @@ GroupGraphPatternSub -> MultiSetPattern = a:TriplesBlock? _ b:GroupGraphPatternS
} }
GroupGraphPatternSub_item -> Vec<PartialGraphPattern> = a:GraphPatternNotTriples _ ('.' _)? b:TriplesBlock? _ { GroupGraphPatternSub_item -> Vec<PartialGraphPattern> = a:GraphPatternNotTriples _ ('.' _)? b:TriplesBlock? _ {
let mut result = vec![a]; let mut result = vec![a];
b.map(|v| result.push(PartialGraphPattern::Other(MultiSetPattern::BGP(v)))); if let Some(v) = b {
result.push(PartialGraphPattern::Other(MultiSetPattern::BGP(v)));
}
result result
} }
@ -270,7 +272,7 @@ TriplesBlock -> Vec<TripleOrPathPattern> = h:TriplesSameSubjectPath _ t:TriplesB
triples triples
} }
TriplesBlock_tail -> Vec<TripleOrPathPattern> = '.' _ t:TriplesBlock? _ { TriplesBlock_tail -> Vec<TripleOrPathPattern> = '.' _ t:TriplesBlock? _ {
t.unwrap_or_else(|| Vec::default()) t.unwrap_or_else(Vec::default)
} }
//[56] //[56]
@ -308,7 +310,9 @@ DataBlock -> MultiSetPattern = l:(InlineDataOneVar / InlineDataFull) {
InlineDataOneVar -> Vec<Binding> = var:Var _ '{' _ d:InlineDataOneVar_value* '}' { InlineDataOneVar -> Vec<Binding> = var:Var _ '{' _ d:InlineDataOneVar_value* '}' {
d.into_iter().map(|val| { d.into_iter().map(|val| {
let mut bindings = Binding::default(); let mut bindings = Binding::default();
val.map(|v| bindings.insert(var.clone(), v)); if let Some(v) = val {
bindings.insert(var.clone(), v);
}
bindings bindings
}).collect() }).collect()
} }
@ -319,7 +323,9 @@ InlineDataFull -> Vec<Binding> = '(' _ vars:InlineDataFull_var* _ ')' _ '{' _ va
val.into_iter().map(|vals| { val.into_iter().map(|vals| {
let mut bindings = Binding::default(); let mut bindings = Binding::default();
for (var, val) in vars.iter().zip(vals.into_iter()) { for (var, val) in vars.iter().zip(vals.into_iter()) {
val.map(|v| bindings.insert(var.clone(), v)); if let Some(v) = val {
bindings.insert(var.clone(), v);
}
} }
bindings bindings
}).collect() }).collect()
@ -359,7 +365,7 @@ Constraint -> Expression = BrackettedExpression / BuiltInCall / FunctionCall
//[70] //[70]
FunctionCall -> Expression = f: iri _ a: ArgList { FunctionCall -> Expression = f: iri _ a: ArgList {
Expression::CustomFunctionCall(f, a.into()) Expression::CustomFunctionCall(f, a)
} }
//[71] //[71]
@ -392,7 +398,7 @@ TriplesSameSubject -> Vec<TriplePattern> =
patterns.push(TriplePattern::new(s.clone(), p.clone(), o)) patterns.push(TriplePattern::new(s.clone(), p.clone(), o))
} }
} }
patterns.into_iter().map(|p| p.into()).collect() patterns
} / } /
s:TriplesNode _ po:PropertyList { s:TriplesNode _ po:PropertyList {
let mut patterns = s.patterns; let mut patterns = s.patterns;
@ -402,7 +408,7 @@ TriplesSameSubject -> Vec<TriplePattern> =
patterns.push(TriplePattern::new(s.focus.clone(), p.clone(), o)) patterns.push(TriplePattern::new(s.focus.clone(), p.clone(), o))
} }
} }
patterns.into_iter().map(|p| p.into()).collect() patterns
} }
//[76] //[76]
@ -420,7 +426,7 @@ PropertyListNotEmpty -> FocusedTriplePattern<Vec<(NamedNodeOrVariable,Vec<TermOr
} }
PropertyListNotEmpty_item -> FocusedTriplePattern<(NamedNodeOrVariable,Vec<TermOrVariable>)> = p:Verb _ o:ObjectList _ { PropertyListNotEmpty_item -> FocusedTriplePattern<(NamedNodeOrVariable,Vec<TermOrVariable>)> = p:Verb _ o:ObjectList _ {
FocusedTriplePattern { FocusedTriplePattern {
focus: (p.into(), o.focus), focus: (p, o.focus),
patterns: o.patterns patterns: o.patterns
} }
} }
@ -558,9 +564,9 @@ PathNegatedPropertySet -> PropertyPath =
Either::Right(b) => inverse.push(b) Either::Right(b) => inverse.push(b)
} }
} }
if inverse.len() == 0 { if inverse.is_empty() {
PropertyPath::NegatedPropertySet(direct) PropertyPath::NegatedPropertySet(direct)
} else if direct.len() == 0 { } else if direct.is_empty() {
PropertyPath::InversePath(Box::new(PropertyPath::NegatedPropertySet(inverse))) PropertyPath::InversePath(Box::new(PropertyPath::NegatedPropertySet(inverse)))
} else { } else {
PropertyPath::AlternativePath( PropertyPath::AlternativePath(
@ -903,7 +909,7 @@ iri -> NamedNode = i:(IRIREF / PrefixedName) {?
//[137] //[137]
PrefixedName -> String = PNAME_LN / PrefixedName -> String = PNAME_LN /
ns:PNAME_NS {? state.namespaces.get(ns).map(|v| v.clone()).ok_or("Prefix not found") } ns:PNAME_NS {? state.namespaces.get(ns).cloned().ok_or("Prefix not found") }
//[138] //[138]
BlankNode -> BlankNode = BlankNode -> BlankNode =

@ -57,7 +57,7 @@ fn hash_blank_nodes(
let mut bnodes_by_hash: HashMap<u64, Vec<BlankNode>> = HashMap::default(); let mut bnodes_by_hash: HashMap<u64, Vec<BlankNode>> = HashMap::default();
// NB: we need to sort the triples to have the same hash // NB: we need to sort the triples to have the same hash
for bnode in bnodes.into_iter() { for bnode in bnodes {
let mut hasher = DefaultHasher::new(); let mut hasher = DefaultHasher::new();
{ {

@ -64,7 +64,7 @@ impl EncodedQuadsStore for MemoryStore {
fn quads(&self) -> Result<<Vec<Result<EncodedQuad>> as IntoIterator>::IntoIter> { fn quads(&self) -> Result<<Vec<Result<EncodedQuad>> as IntoIterator>::IntoIter> {
let mut result = Vec::default(); let mut result = Vec::default();
for (graph_name, graph) in self.graph_indexes.read()?.iter() { for (graph_name, graph) in self.graph_indexes.read()?.iter() {
for (s, pos) in graph.spo.iter() { for (s, pos) in &graph.spo {
for (p, os) in pos.iter() { for (p, os) in pos.iter() {
for o in os.iter() { for o in os.iter() {
result.push(Ok(encoded_quad(s, p, o, graph_name))) result.push(Ok(encoded_quad(s, p, o, graph_name)))
@ -205,7 +205,7 @@ impl EncodedQuadsStore for MemoryStore {
) -> Result<<Vec<Result<EncodedQuad>> as IntoIterator>::IntoIter> { ) -> Result<<Vec<Result<EncodedQuad>> as IntoIterator>::IntoIter> {
let mut result = Vec::default(); let mut result = Vec::default();
if let Some(graph) = self.graph_indexes.read()?.get(graph_name) { if let Some(graph) = self.graph_indexes.read()?.get(graph_name) {
for (s, pos) in graph.spo.iter() { for (s, pos) in &graph.spo {
for (p, os) in pos.iter() { for (p, os) in pos.iter() {
for o in os.iter() { for o in os.iter() {
result.push(Ok(encoded_quad(s, p, o, graph_name))) result.push(Ok(encoded_quad(s, p, o, graph_name)))
@ -340,10 +340,8 @@ impl EncodedQuadsStore for MemoryStore {
po.get(&quad.predicate) po.get(&quad.predicate)
.map(|o| o.contains(&quad.object)) .map(|o| o.contains(&quad.object))
.unwrap_or(false) .unwrap_or(false)
}) }).unwrap_or(false)
.unwrap_or(false) }).unwrap_or(false))
})
.unwrap_or(false))
} }
fn insert(&self, quad: &EncodedQuad) -> Result<()> { fn insert(&self, quad: &EncodedQuad) -> Result<()> {

@ -213,7 +213,7 @@ impl<S: BytesStore> Encoder<S> {
} }
pub fn encode_blank_node(&self, blank_node: &BlankNode) -> Result<EncodedTerm> { pub fn encode_blank_node(&self, blank_node: &BlankNode) -> Result<EncodedTerm> {
Ok(EncodedTerm::BlankNode(blank_node.deref().clone())) Ok(EncodedTerm::BlankNode(*blank_node.deref()))
} }
pub fn encode_literal(&self, literal: &Literal) -> Result<EncodedTerm> { pub fn encode_literal(&self, literal: &Literal) -> Result<EncodedTerm> {
@ -347,7 +347,7 @@ impl<S: BytesStore> Encoder<S> {
fn decode_value(&self, id: u64) -> Result<S::BytesOutput> { fn decode_value(&self, id: u64) -> Result<S::BytesOutput> {
self.string_store self.string_store
.get_bytes(id)? .get_bytes(id)?
.ok_or("value not found in the dictionary".into()) .ok_or_else(|| "value not found in the dictionary".into())
} }
} }

@ -23,17 +23,17 @@ impl RocksDbDataset {
} }
} }
const ID2STR_CF: &'static str = "id2str"; const ID2STR_CF: &str = "id2str";
const STR2ID_CF: &'static str = "id2str"; const STR2ID_CF: &str = "id2str";
const SPOG_CF: &'static str = "spog"; const SPOG_CF: &str = "spog";
const POSG_CF: &'static str = "posg"; const POSG_CF: &str = "posg";
const OSPG_CF: &'static str = "ospg"; const OSPG_CF: &str = "ospg";
const EMPTY_BUF: [u8; 0] = [0 as u8; 0]; const EMPTY_BUF: [u8; 0] = [0 as u8; 0];
//TODO: indexes for the default graph and indexes for the named graphs (no more Optional and space saving) //TODO: indexes for the default graph and indexes for the named graphs (no more Optional and space saving)
const COLUMN_FAMILIES: [&'static str; 5] = [ID2STR_CF, STR2ID_CF, SPOG_CF, POSG_CF, OSPG_CF]; const COLUMN_FAMILIES: [&str; 5] = [ID2STR_CF, STR2ID_CF, SPOG_CF, POSG_CF, OSPG_CF];
pub struct RocksDbStore { pub struct RocksDbStore {
db: DB, db: DB,
@ -322,7 +322,8 @@ impl EncodedQuadsStore for RocksDbStore {
batch.put_cf(self.spog_cf, &encode_spog_quad(quad)?, &EMPTY_BUF)?; batch.put_cf(self.spog_cf, &encode_spog_quad(quad)?, &EMPTY_BUF)?;
batch.put_cf(self.posg_cf, &encode_posg_quad(quad)?, &EMPTY_BUF)?; batch.put_cf(self.posg_cf, &encode_posg_quad(quad)?, &EMPTY_BUF)?;
batch.put_cf(self.ospg_cf, &encode_ospg_quad(quad)?, &EMPTY_BUF)?; batch.put_cf(self.ospg_cf, &encode_ospg_quad(quad)?, &EMPTY_BUF)?;
Ok(self.db.write(batch)?) //TODO: check what's going on if the key already exists self.db.write(batch)?; //TODO: check what's going on if the key already exists
Ok(())
} }
fn remove(&self, quad: &EncodedQuad) -> Result<()> { fn remove(&self, quad: &EncodedQuad) -> Result<()> {
@ -330,7 +331,8 @@ impl EncodedQuadsStore for RocksDbStore {
batch.delete_cf(self.spog_cf, &encode_spog_quad(quad)?)?; batch.delete_cf(self.spog_cf, &encode_spog_quad(quad)?)?;
batch.delete_cf(self.posg_cf, &encode_posg_quad(quad)?)?; batch.delete_cf(self.posg_cf, &encode_posg_quad(quad)?)?;
batch.delete_cf(self.ospg_cf, &encode_ospg_quad(quad)?)?; batch.delete_cf(self.ospg_cf, &encode_ospg_quad(quad)?)?;
Ok(self.db.write(batch)?) self.db.write(batch)?;
Ok(())
} }
} }

@ -276,7 +276,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()? { for quad in self.iter()? {
write!(fmt, "{}\n", quad?)?; writeln!(fmt, "{}", quad?)?;
} }
Ok(()) Ok(())
} }
@ -465,7 +465,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()? { for triple in self.iter()? {
write!(fmt, "{}\n", triple?)?; writeln!(fmt, "{}", triple?)?;
} }
Ok(()) Ok(())
} }
@ -620,7 +620,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()? { for triple in self.iter()? {
write!(fmt, "{}\n", triple?)?; writeln!(fmt, "{}", triple?)?;
} }
Ok(()) Ok(())
} }
@ -761,8 +761,7 @@ impl<S: EncodedQuadsStore> Graph for StoreUnionGraph<S> {
&encoder.encode_named_or_blank_node(triple.subject())?, &encoder.encode_named_or_blank_node(triple.subject())?,
&encoder.encode_named_node(triple.predicate())?, &encoder.encode_named_node(triple.predicate())?,
&encoder.encode_term(triple.object())?, &encoder.encode_term(triple.object())?,
)? )?.any(|_| true))
.any(|_| true))
} }
fn insert(&self, triple: &Triple) -> Result<()> { fn insert(&self, triple: &Triple) -> Result<()> {
@ -785,7 +784,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()? { for triple in self.iter()? {
write!(fmt, "{}\n", triple?)?; writeln!(fmt, "{}", triple?)?;
} }
Ok(()) Ok(())
} }

@ -4,13 +4,13 @@ pub trait Escaper {
impl<'a> Escaper for &'a str { impl<'a> Escaper for &'a str {
fn escape(&self) -> String { fn escape(&self) -> String {
self.chars().flat_map(|c| EscapeRDF::new(c)).collect() self.chars().flat_map(EscapeRDF::new).collect()
} }
} }
impl Escaper for String { impl Escaper for String {
fn escape(&self) -> String { fn escape(&self) -> String {
self.chars().flat_map(|c| EscapeRDF::new(c)).collect() self.chars().flat_map(EscapeRDF::new).collect()
} }
} }

@ -95,11 +95,10 @@ fn turtle_w3c_testsuite() {
.map(|r| client.load_turtle(r)) .map(|r| client.load_turtle(r))
.unwrap_or_else(|| Ok(MemoryGraph::default())); .unwrap_or_else(|| Ok(MemoryGraph::default()));
assert!( assert!(
action_graph.is_err() action_graph.is_err() || !action_graph
|| !action_graph .unwrap()
.unwrap() .is_isomorphic(&result_graph.unwrap())
.is_isomorphic(&result_graph.unwrap()) .unwrap(),
.unwrap(),
"Failure on {}", "Failure on {}",
test test
); );
@ -252,21 +251,21 @@ pub mod mf {
use std::str::FromStr; use std::str::FromStr;
lazy_static! { lazy_static! {
pub static ref INCLUDE: NamedNode = NamedNode::from_str( pub static ref INCLUDE: NamedNode =
"http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#include" NamedNode::from_str("http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#include")
).unwrap(); .unwrap();
pub static ref ENTRIES: NamedNode = NamedNode::from_str( pub static ref ENTRIES: NamedNode =
"http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#entries" NamedNode::from_str("http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#entries")
).unwrap(); .unwrap();
pub static ref NAME: NamedNode = NamedNode::from_str( pub static ref NAME: NamedNode =
"http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#name" NamedNode::from_str("http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#name")
).unwrap(); .unwrap();
pub static ref ACTION: NamedNode = NamedNode::from_str( pub static ref ACTION: NamedNode =
"http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#action" NamedNode::from_str("http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#action")
).unwrap(); .unwrap();
pub static ref RESULT: NamedNode = NamedNode::from_str( pub static ref RESULT: NamedNode =
"http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#result" NamedNode::from_str("http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#result")
).unwrap(); .unwrap();
} }
} }

Loading…
Cancel
Save