pub struct RcStatefulPredicate<T> { /* private fields */ }Expand description
An Rc-based stateful predicate with single-threaded shared ownership.
This type stores the predicate closure inside Rc<RefCell<_>>, allowing
cheap clones that share the same mutable predicate state on one thread.
Implementations§
Source§impl<T> RcStatefulPredicate<T>
impl<T> RcStatefulPredicate<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 RcStatefulPredicate that always returns true.
Sourcepub fn always_false() -> Self
pub fn always_false() -> Self
Creates a predicate that always returns false.
§Returns
A new RcStatefulPredicate that always returns false.
Sourcepub fn and<P>(&self, other: P) -> RcStatefulPredicate<T>where
P: StatefulPredicate<T> + 'static,
T: 'static,
pub fn and<P>(&self, other: P) -> RcStatefulPredicate<T>where
P: StatefulPredicate<T> + '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 Rc<RefCell<_>>.
§Parameters
other- The other predicate to combine with.
§Returns
A new RcStatefulPredicate representing logical AND.
Sourcepub fn or<P>(&self, other: P) -> RcStatefulPredicate<T>where
P: StatefulPredicate<T> + 'static,
T: 'static,
pub fn or<P>(&self, other: P) -> RcStatefulPredicate<T>where
P: StatefulPredicate<T> + '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 Rc<RefCell<_>>.
§Parameters
other- The other predicate to combine with.
§Returns
A new RcStatefulPredicate representing logical OR.
Sourcepub fn nand<P>(&self, other: P) -> RcStatefulPredicate<T>where
P: StatefulPredicate<T> + 'static,
T: 'static,
pub fn nand<P>(&self, other: P) -> RcStatefulPredicate<T>where
P: StatefulPredicate<T> + 'static,
T: 'static,
Sourcepub fn xor<P>(&self, other: P) -> RcStatefulPredicate<T>where
P: StatefulPredicate<T> + 'static,
T: 'static,
pub fn xor<P>(&self, other: P) -> RcStatefulPredicate<T>where
P: StatefulPredicate<T> + 'static,
T: 'static,
Sourcepub fn nor<P>(&self, other: P) -> RcStatefulPredicate<T>where
P: StatefulPredicate<T> + 'static,
T: 'static,
pub fn nor<P>(&self, other: P) -> RcStatefulPredicate<T>where
P: StatefulPredicate<T> + 'static,
T: 'static,
Trait Implementations§
Source§impl<T> Clone for RcStatefulPredicate<T>
impl<T> Clone for RcStatefulPredicate<T>
Source§impl<T> Debug for RcStatefulPredicate<T>
impl<T> Debug for RcStatefulPredicate<T>
Source§impl<T> Display for RcStatefulPredicate<T>
impl<T> Display for RcStatefulPredicate<T>
Source§impl<T> Not for &RcStatefulPredicate<T>where
T: 'static,
impl<T> Not for &RcStatefulPredicate<T>where
T: 'static,
Source§impl<T> Not for RcStatefulPredicate<T>where
T: 'static,
impl<T> Not for RcStatefulPredicate<T>where
T: 'static,
Source§impl<T> StatefulPredicate<T> for RcStatefulPredicate<T>
impl<T> StatefulPredicate<T> for RcStatefulPredicate<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>
fn into_rc(self) -> RcStatefulPredicate<T>
RcStatefulPredicate. 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>
fn to_rc(&self) -> RcStatefulPredicate<T>
RcStatefulPredicate. Read moreSource§fn to_fn(&self) -> impl FnMut(&T) -> bool
fn to_fn(&self) -> impl FnMut(&T) -> bool
Source§fn into_arc(self) -> ArcStatefulPredicate<T>
fn into_arc(self) -> ArcStatefulPredicate<T>
ArcStatefulPredicate. Read more