Code format cleanup

pull/10/head
Tpt 7 years ago
parent fec8868065
commit dda9c8e5b7
  1. 6
      src/model/data.rs
  2. 14
      src/rio/ntriples/mod.rs
  3. 8
      src/rio/turtle/mod.rs

@ -1,13 +1,13 @@
///! Implements data structures for https://www.w3.org/TR/rdf11-concepts/
///! Inspired by [RDFjs](http://rdf.js.org/)
use std::fmt;
use std::ops::Deref;
use std::option::Option;
use std::str::FromStr;
use std::sync::Arc;
use url::ParseError;
use url::Url;
use uuid::Uuid;
use std::ops::Deref;
/// A RDF [IRI](https://www.w3.org/TR/rdf11-concepts/#dfn-iri)
#[derive(Eq, PartialEq, Ord, PartialOrd, Debug, Clone, Hash)]
@ -77,9 +77,7 @@ impl fmt::Display for BlankNode {
impl Default for BlankNode {
/// Builds a new RDF [blank node](https://www.w3.org/TR/rdf11-concepts/#dfn-blank-node) with a unique id
fn default() -> Self {
BlankNode {
id: Uuid::new_v4()
}
BlankNode { id: Uuid::new_v4() }
}
}

@ -6,20 +6,20 @@ mod grammar {
use model::data::*;
use rio::*;
use std::collections::BTreeMap;
use std::io::BufRead;
use std::io::BufReader;
use std::io::Read;
use std::collections::BTreeMap;
pub fn read_ntriples<'a, R: Read + 'a>(source: R) -> impl Iterator<Item = RioResult<Triple>> {
//TODO: use read_lines to avoid allocations
let lines = BufReader::new(source).lines();
let mut bnodes_map: BTreeMap<String, BlankNode> = BTreeMap::default();
lines.flat_map(move |line| match line {
Ok(line) => match grammar::triple(line.as_str(), &mut bnodes_map) {
Ok(triple) => Some(Ok(triple?)),
Err(error) => Some(Err(RioError::new(error))),
},
Err(error) => Some(Err(error.into())),
})
Ok(line) => match grammar::triple(line.as_str(), &mut bnodes_map) {
Ok(triple) => Some(Ok(triple?)),
Err(error) => Some(Err(RioError::new(error))),
},
Err(error) => Some(Err(error.into())),
})
}

@ -5,19 +5,19 @@ mod grammar {
use model::data::*;
use rio::*;
use std::collections::BTreeMap;
use std::collections::HashMap;
use std::io::BufReader;
use std::io::Read;
use url::ParseOptions;
use url::Url;
use std::collections::BTreeMap;
pub struct ParserState {
base_uri: Option<Url>,
namespaces: HashMap<String, String>,
cur_subject: Vec<NamedOrBlankNode>,
cur_predicate: Vec<NamedNode>,
bnodes_map: BTreeMap<String, BlankNode>
bnodes_map: BTreeMap<String, BlankNode>,
}
impl ParserState {
@ -35,7 +35,7 @@ mod grammar {
namespaces: HashMap::default(),
cur_subject: Vec::default(),
cur_predicate: Vec::default(),
bnodes_map: BTreeMap::default()
bnodes_map: BTreeMap::default(),
};
let mut triple_buffer = Vec::default();
@ -49,4 +49,4 @@ mod grammar {
}
}
pub use self::grammar::read_turtle;
pub use self::grammar::read_turtle;

Loading…
Cancel
Save