Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ backtrace = "0.3"
cfg-if = "1"
cidr = { version = "0.2", features = ["serde"] }
criterion = "0.5"
dyn-clone = "1.0.20"
fnv = "1.0.6"
getrandom = { version = "0.3" }
indoc = "2"
Expand Down
1 change: 1 addition & 0 deletions engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ harness = false
backtrace.workspace = true
cfg-if.workspace = true
cidr.workspace = true
dyn-clone.workspace = true
fnv.workspace = true
memmem.workspace = true
rand.workspace = true
Expand Down
11 changes: 11 additions & 0 deletions engine/src/execution_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,17 @@ impl<'e, U> ExecutionContext<'e, U> {
ExecutionContextGuard::new(self, user_data)
}

/// Clone the current [`ExecutionContext`] into a new one.
#[inline]
pub fn clone_with<T>(&self, user_data: T) -> ExecutionContext<'e, T> {
ExecutionContext {
scheme: self.scheme.clone(),
values: self.values.clone(),
list_matchers: self.list_matchers.clone(),
user_data,
}
}

/// Clears the execution context, removing all values and lists
/// while retaining the allocated memory.
#[inline]
Expand Down
5 changes: 4 additions & 1 deletion engine/src/list_matcher.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::LhsValue;
use crate::Type;
use dyn_clone::DynClone;
use serde_json::Value;
use std::any::Any;
use std::fmt::Debug;
Expand Down Expand Up @@ -58,7 +59,7 @@ impl<T: PartialEq + Any> DynPartialEq for T {
}

/// Implement this Trait to match a given `LhsValue` against a list.
pub trait ListMatcher: AsAny + Debug + DynPartialEq + Send + Sync + 'static {
pub trait ListMatcher: AsAny + Debug + DynClone + DynPartialEq + Send + Sync + 'static {
/// Returns true if `val` is in the given list.
fn match_value(&self, list_name: &str, val: &LhsValue<'_>) -> bool;

Expand All @@ -69,6 +70,8 @@ pub trait ListMatcher: AsAny + Debug + DynPartialEq + Send + Sync + 'static {
fn clear(&mut self);
}

dyn_clone::clone_trait_object!(ListMatcher);

impl PartialEq for dyn ListMatcher {
#[inline]
fn eq(&self, other: &dyn ListMatcher) -> bool {
Expand Down
Loading