Skip to content

Commit 89bd514

Browse files
committed
add PredicateEvaluator::evaluate_predicate_with_direction
1 parent 93c4741 commit 89bd514

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

src/internals/postfix_stack_item.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@ pub(crate) enum PostfixStackItem<'a, Predicate> {
66
}
77

88
impl<Predicate> PostfixStackItem<'_, Predicate> {
9-
pub(crate) fn evaluate<Reason>(
9+
pub(crate) fn evaluate<Reason, Direction>(
1010
&self,
11-
evaluator: &dyn PredicateEvaluator<Predicate = Predicate, Reason = Reason>,
11+
evaluator: &dyn PredicateEvaluator<
12+
Predicate = Predicate,
13+
Reason = Reason,
14+
Direction = Direction,
15+
>,
1216
reasons: &mut Vec<Reason>,
1317
) -> bool {
1418
match self {

src/structs/postfix_expression.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,13 @@ impl<Predicate> PostfixExpression<Predicate> {
5858
InfixExpression::from_tokens_unchecked(output_stack.remove(0).into())
5959
}
6060

61-
pub fn evaluate<Reason>(
61+
pub fn evaluate<Reason, Direction>(
6262
&self,
63-
evaluator: &dyn PredicateEvaluator<Predicate = Predicate, Reason = Reason>,
63+
evaluator: &dyn PredicateEvaluator<
64+
Predicate = Predicate,
65+
Reason = Reason,
66+
Direction = Direction,
67+
>,
6468
) -> (bool, Vec<Reason>) {
6569
let mut stack: Vec<PostfixStackItem<Predicate>> = Vec::new();
6670
let mut reasons: Vec<Reason> = Vec::new();

src/traits/predicate_evaluator.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
pub trait PredicateEvaluator {
22
type Predicate;
33
type Reason;
4+
type Direction;
45

5-
fn evaluate_predicate(&self, predicate: &Self::Predicate) -> bool;
6+
fn evaluate_predicate(&self, _predicate: &Self::Predicate) -> bool {
7+
false
8+
}
9+
10+
fn evaluate_predicate_with_direction(
11+
&self,
12+
_predicate: &Self::Predicate,
13+
_direction: &Self::Direction,
14+
) -> bool {
15+
false
16+
}
617

718
fn get_reason(&self, predicate: &Self::Predicate) -> Self::Reason;
819

0 commit comments

Comments
 (0)