diff --git a/shex_validation/src/validator_runner.rs b/shex_validation/src/validator_runner.rs index 1f9a1434..719d1be0 100644 --- a/shex_validation/src/validator_runner.rs +++ b/shex_validation/src/validator_runner.rs @@ -377,7 +377,7 @@ impl ValidatorRunner { S: SRDF, { let node = self.get_rdf_node(node, rdf); - let list = preds.iter().map(|pred| S::iri_s2iri(pred)).collect(); + let list: Vec<_> = preds.iter().map(|pred| S::iri_s2iri(pred)).collect(); if let Some(subject) = S::term_as_subject(&node) { let (outgoing_arcs, remainder) = rdf .outgoing_arcs_from_list(&subject, &list) diff --git a/sparql_service/src/srdf_data/rdf_data.rs b/sparql_service/src/srdf_data/rdf_data.rs index 873ce262..b11b23df 100644 --- a/sparql_service/src/srdf_data/rdf_data.rs +++ b/sparql_service/src/srdf_data/rdf_data.rs @@ -93,6 +93,12 @@ impl RdfData { } } +impl Default for RdfData { + fn default() -> Self { + Self::new() + } +} + impl SRDFBasic for RdfData { type IRI = OxNamedNode; type BNode = OxBlankNode; @@ -366,11 +372,11 @@ fn cnv_query_solution(qs: QuerySolution) -> QuerySolution2 { let mut variables = Vec::new(); let mut values = Vec::new(); for v in qs.variables() { - let varname = VarName2::from_str(v.as_str()); + let varname = VarName2::new(v.as_str()); variables.push(varname); } for t in qs.values() { - let term = t.as_ref().map(|t| t.clone()); + let term = t.clone(); values.push(term) } QuerySolution2::new(Rc::new(variables), values) @@ -447,7 +453,7 @@ impl SRDF for RdfData { fn outgoing_arcs_from_list( &self, subject: &Self::Subject, - preds: &Vec, + preds: &[Self::IRI], ) -> Result<(HashMap>, Vec), Self::Err> { let mut result = (HashMap::new(), Vec::new()); if let Some(graph) = &self.graph { diff --git a/srdf/src/query_srdf2.rs b/srdf/src/query_srdf2.rs index 80ef9589..99259f6e 100644 --- a/srdf/src/query_srdf2.rs +++ b/srdf/src/query_srdf2.rs @@ -23,7 +23,7 @@ impl Display for VarName2 { } impl VarName2 { - pub fn from_str(str: &str) -> VarName2 { + pub fn new(str: &str) -> VarName2 { VarName2 { str: str.to_string(), } @@ -88,10 +88,7 @@ impl QuerySolution2 { let cnv_values: Vec> = self .values .iter() - .map(|s| match s { - None => None, - Some(s) => Some(cnv_term(s)), - }) + .map(|s| s.as_ref().map(&cnv_term)) .collect(); QuerySolution2 { variables: self.variables.clone(), diff --git a/srdf/src/srdf.rs b/srdf/src/srdf.rs index 5af44f29..9dd6f1ad 100644 --- a/srdf/src/srdf.rs +++ b/srdf/src/srdf.rs @@ -76,6 +76,6 @@ pub trait SRDF: SRDFBasic { fn outgoing_arcs_from_list( &self, subject: &Self::Subject, - preds: &Vec, + preds: &[Self::IRI], ) -> Result, Self::Err>; } diff --git a/srdf/src/srdf_graph/srdfgraph.rs b/srdf/src/srdf_graph/srdfgraph.rs index 5ce0aabf..6a91e72f 100644 --- a/srdf/src/srdf_graph/srdfgraph.rs +++ b/srdf/src/srdf_graph/srdfgraph.rs @@ -562,7 +562,7 @@ impl SRDF for SRDFGraph { fn outgoing_arcs_from_list( &self, subject: &Self::Subject, - preds: &Vec, + preds: &[Self::IRI], ) -> Result<(HashMap>, Vec), Self::Err> { let mut results: HashMap> = HashMap::new(); let mut remainder = Vec::new(); diff --git a/srdf/src/srdf_sparql/srdfsparql.rs b/srdf/src/srdf_sparql/srdfsparql.rs index b7738f02..3ba9f5e1 100644 --- a/srdf/src/srdf_sparql/srdfsparql.rs +++ b/srdf/src/srdf_sparql/srdfsparql.rs @@ -381,7 +381,7 @@ impl SRDF for SRDFSparql { fn outgoing_arcs_from_list( &self, subject: &Self::Subject, - preds: &Vec, + preds: &[Self::IRI], ) -> std::prelude::v1::Result< (HashMap>, Vec), Self::Err, @@ -431,7 +431,7 @@ impl QuerySRDF2 for SRDFSparql { fn query_select(&self, query: &str) -> Result> { let solutions = make_sparql_query(query, &self.client, &self.endpoint_iri)?; let qs: Vec> = - solutions.iter().map(|s| cnv_query_solution(s)).collect(); + solutions.iter().map(cnv_query_solution).collect(); Ok(QuerySolutions::new(qs)) } @@ -452,14 +452,11 @@ fn cnv_query_solution(qs: &OxQuerySolution) -> QuerySolution2 { let mut variables = Vec::new(); let mut values = Vec::new(); for v in qs.variables() { - let varname = VarName2::from_str(v.as_str()); + let varname = VarName2::new(v.as_str()); variables.push(varname); } for t in qs.values() { - let term = match &t { - None => None, - Some(t) => Some(t.clone()), - }; + let term = t.clone(); values.push(term) } QuerySolution2::new(Rc::new(variables), values) @@ -579,7 +576,7 @@ type OutputNodes = HashMap>; fn outgoing_neighs_from_list( subject: &OxSubject, - preds: &Vec, + preds: &[OxNamedNode], client: &Client, endpoint_iri: &IriS, ) -> Result<(OutputNodes, Vec)> {