From 725595f04533e5aab05ad445f830e81c0b474e8d Mon Sep 17 00:00:00 2001 From: cmdoret Date: Tue, 6 Aug 2024 17:51:09 +0200 Subject: [PATCH] refactor(rules): explicit matches --- src/rules.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/rules.rs b/src/rules.rs index e7d7843..d338989 100644 --- a/src/rules.rs +++ b/src/rules.rs @@ -61,11 +61,12 @@ pub fn match_subject_rules( ) -> TripleMask { let pseudo_subject = match &triple.subject { Subject::NamedNode(n) => match_type(&n.iri, rules, type_map), - _ => false, + Subject::BlankNode(_) => false, }; let pseudo_object = match &triple.object { Term::NamedNode(n) => match_type(&n.iri, rules, type_map), - _ => false, + Term::BlankNode(_) => false, + Term::Literal(_) => false, }; let mut mask = TripleMask::default(); @@ -99,20 +100,19 @@ pub fn match_object_rules( }, }; - let mask = if pseudo_object { - TripleMask::OBJECT - } else { - TripleMask::default() - }; + if pseudo_object { + return TripleMask::OBJECT + } - return mask; + return TripleMask::default() } /// Check if the type of input instance URI is in the rules. fn match_type(subject: &str, rules: &Rules, type_map: &HashMap) -> bool { - match type_map.get(subject) { - Some(v) => rules.subjects.of_type.contains(v), - None => false, + if let Some(v) = type_map.get(subject) { + rules.subjects.of_type.contains(v) + } else { + false } }