pub struct ArcStatefulPredicate<T> { /* private fields */ }Expand description
An Arc-based stateful predicate with thread-safe shared ownership.
This type stores the predicate closure inside Arc<Mutex<_>>, allowing
cheap clones that share mutable predicate state across threads.
Implementations§
Source§impl<T> ArcStatefulPredicate<T>
impl<T> ArcStatefulPredicate<T>
Sourcepub fn new<F>(f: F) -> Self
pub fn new<F>(f: F) -> Self
Creates a new predicate.
Wraps the provided closure in the appropriate smart pointer type for this predicate implementation.
Sourcepub fn new_with_name<F>(name: &str, f: F) -> Self
pub fn new_with_name<F>(name: &str, f: F) -> Self
Creates a new named predicate.
Wraps the provided closure and assigns it a name, which is useful for debugging and logging purposes.
Sourcepub fn new_with_optional_name<F>(f: F, name: Option<String>) -> Self
pub fn new_with_optional_name<F>(f: F, name: Option<String>) -> Self
Creates a new named predicate with an optional name.
Wraps the provided closure and assigns it an optional name.
Sourcepub fn clear_name(&mut self)
pub fn clear_name(&mut self)
Clears the name of this predicate.
Sourcepub fn always_true() -> Self
pub fn always_true() -> Self
Creates a predicate that always returns true.
§Returns
A new ArcStatefulPredicate that always returns true.
Sourcepub fn always_false() -> Self
pub fn always_false() -> Self
Creates a predicate that always returns false.
§Returns
A new ArcStatefulPredicate that always returns false.
Sourcepub fn and<P>(&self, other: P) -> ArcStatefulPredicate<T>where
P: StatefulPredicate<T> + Send + 'static,
T: 'static,
pub fn and<P>(&self, other: P) -> ArcStatefulPredicate<T>where
P: StatefulPredicate<T> + Send + 'static,
T: 'static,
Returns a predicate representing logical AND with another predicate.
This method borrows self; the returned predicate shares this
predicate’s mutable state through the same Arc<Mutex<_>>.
§Parameters
other- The other predicate to combine with.
§Returns
A new ArcStatefulPredicate representing logical AND.
Sourcepub fn or<P>(&self, other: P) -> ArcStatefulPredicate<T>where
P: StatefulPredicate<T> + Send + 'static,
T: 'static,
pub fn or<P>(&self, other: P) -> ArcStatefulPredicate<T>where
P: StatefulPredicate<T> + Send + 'static,
T: 'static,
Returns a predicate representing logical OR with another predicate.
This method borrows self; the returned predicate shares this
predicate’s mutable state through the same Arc<Mutex<_>>.
§Parameters
other- The other predicate to combine with.
§Returns
A new ArcStatefulPredicate representing logical OR.
Sourcepub fn nand<P>(&self, other: P) -> ArcStatefulPredicate<T>where
P: StatefulPredicate<T> + Send + 'static,
T: 'static,
pub fn nand<P>(&self, other: P) -> ArcStatefulPredicate<T>where
P: StatefulPredicate<T> + Send + 'static,
T: 'static,
Sourcepub fn xor<P>(&self, other: P) -> ArcStatefulPredicate<T>where
P: StatefulPredicate<T> + Send + 'static,
T: 'static,
pub fn xor<P>(&self, other: P) -> ArcStatefulPredicate<T>where
P: StatefulPredicate<T> + Send + 'static,
T: 'static,
Sourcepub fn nor<P>(&self, other: P) -> ArcStatefulPredicate<T>where
P: StatefulPredicate<T> + Send + 'static,
T: 'static,
pub fn nor<P>(&self, other: P) -> ArcStatefulPredicate<T>where
P: StatefulPredicate<T> + Send + 'static,
T: 'static,
Trait Implementations§
Source§impl<T> Clone for ArcStatefulPredicate<T>
impl<T> Clone for ArcStatefulPredicate<T>
Source§impl<T> Debug for ArcStatefulPredicate<T>
impl<T> Debug for ArcStatefulPredicate<T>
Source§impl<T> Display for ArcStatefulPredicate<T>
impl<T> Display for ArcStatefulPredicate<T>
Source§impl<T> Not for &ArcStatefulPredicate<T>where
T: 'static,
impl<T> Not for &ArcStatefulPredicate<T>where
T: 'static,
Source§impl<T> Not for ArcStatefulPredicate<T>where
T: 'static,
impl<T> Not for ArcStatefulPredicate<T>where
T: 'static,
Source§impl<T> StatefulPredicate<T> for ArcStatefulPredicate<T>
impl<T> StatefulPredicate<T> for ArcStatefulPredicate<T>
Source§fn test(&mut self, value: &T) -> bool
fn test(&mut self, value: &T) -> bool
Source§fn into_box(self) -> BoxStatefulPredicate<T>where
Self: 'static,
fn into_box(self) -> BoxStatefulPredicate<T>where
Self: 'static,
BoxStatefulPredicate. Read moreSource§fn into_rc(self) -> RcStatefulPredicate<T>where
Self: 'static,
fn into_rc(self) -> RcStatefulPredicate<T>where
Self: 'static,
RcStatefulPredicate. Read moreSource§fn into_arc(self) -> ArcStatefulPredicate<T>
fn into_arc(self) -> ArcStatefulPredicate<T>
ArcStatefulPredicate. Read moreSource§fn into_fn(self) -> impl FnMut(&T) -> bool
fn into_fn(self) -> impl FnMut(&T) -> bool
FnMut(&T) -> bool. Read moreSource§fn to_box(&self) -> BoxStatefulPredicate<T>where
Self: 'static,
fn to_box(&self) -> BoxStatefulPredicate<T>where
Self: 'static,
BoxStatefulPredicate. Read moreSource§fn to_rc(&self) -> RcStatefulPredicate<T>where
Self: 'static,
fn to_rc(&self) -> RcStatefulPredicate<T>where
Self: 'static,
RcStatefulPredicate. Read moreSource§fn to_arc(&self) -> ArcStatefulPredicate<T>
fn to_arc(&self) -> ArcStatefulPredicate<T>
ArcStatefulPredicate. Read more