Skip to content

Commit

Permalink
feat: added get_range method
Browse files Browse the repository at this point in the history
  • Loading branch information
m62624 committed Aug 27, 2023
1 parent 4adefb3 commit 4eae649
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions flexible_inspect_rs/src/rules/rule_bytes/base.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use super::range::Range;
use super::SimpleRulesBytes;
use super::*;
use crate::rules::traits::RuleBase;
Expand Down Expand Up @@ -42,4 +43,8 @@ impl RuleBase for RuleBytes {
fn get_complex_rules(&self) -> Option<&IndexSet<Self::RuleType>> {
None
}

fn get_range(&self) -> Option<&Range> {
self.0.general_modifiers.range.as_ref()
}
}
5 changes: 5 additions & 0 deletions flexible_inspect_rs/src/rules/rule_str/base.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use super::range::Range;
use super::*;
use crate::rules::traits::RuleBase;

Expand Down Expand Up @@ -47,4 +48,8 @@ impl RuleBase for Rule {
}
None
}

fn get_range(&self) -> Option<&Range> {
self.0.general_modifiers.range.as_ref()
}
}
3 changes: 2 additions & 1 deletion flexible_inspect_rs/src/rules/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ They are necessary to avoid code duplicates. Especially in context_match, where
*/

// =======================================================
use super::common_elements::range::{RangeBoundaries, RangeMode};
use super::common_elements::range::*;
use super::{CaptureData, Counter, ModeMatch};
use crate::prelude::MatchRequirement;
use indexmap::IndexSet;
Expand All @@ -26,6 +26,7 @@ pub trait RuleBase {
fn get_counter(&self) -> Option<Counter>;
fn get_mode_match(&self) -> &ModeMatch;
fn get_str(&self) -> &str;
fn get_range(&self) -> Option<&Range>;
}

/// The main trait for `context_match`, that is,
Expand Down

0 comments on commit 4eae649

Please sign in to comment.