From c46fa7fe21264d7977bf7b6dc788849e21a5dc77 Mon Sep 17 00:00:00 2001 From: Vincent Thiberville Date: Sun, 8 Oct 2023 16:09:36 +0200 Subject: [PATCH] refacto: remove pub attribute in VarMatches fields --- boreal/src/evaluator/variable.rs | 9 +++++++-- boreal/src/scanner/mod.rs | 4 +--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/boreal/src/evaluator/variable.rs b/boreal/src/evaluator/variable.rs index 85ca1b51..e27d9b2b 100644 --- a/boreal/src/evaluator/variable.rs +++ b/boreal/src/evaluator/variable.rs @@ -10,12 +10,17 @@ pub(crate) struct VarMatches<'a> { /// Matches per variable. /// /// This uses the same order as the variables vec in the scanner object. - pub(crate) matches: &'a [Vec], + matches: &'a [Vec], } type Match = std::ops::Range; -impl VarMatches<'_> { +impl<'a> VarMatches<'a> { + /// Create a new `VarMatches` object from a list of variable matches. + pub fn new(matches: &'a [Vec]) -> Self { + Self { matches } + } + /// Return true if the variable can be found in the scanned memory. pub fn find(&self, var_index: usize) -> bool { !self.matches[var_index].is_empty() diff --git a/boreal/src/scanner/mod.rs b/boreal/src/scanner/mod.rs index 26c51aab..61cda199 100644 --- a/boreal/src/scanner/mod.rs +++ b/boreal/src/scanner/mod.rs @@ -347,9 +347,7 @@ impl Inner { let var_matches = collect_nb_elems(&mut ac_matches_iter, rule.nb_variables); let res = match evaluate_rule( rule, - Some(VarMatches { - matches: &var_matches, - }), + Some(VarMatches::new(&var_matches)), &mut scan_data, &previous_results, ) {