Struct predicates::function::FnPredicate
source · pub struct FnPredicate<F, T>where
F: Fn(&T) -> bool,
T: ?Sized,{ /* private fields */ }
Expand description
Predicate that wraps a function over a reference that returns a bool
.
This type is returned by the predicate::function
function.
Implementations§
source§impl<F, T> FnPredicate<F, T>where
F: Fn(&T) -> bool,
T: ?Sized,
impl<F, T> FnPredicate<F, T>where F: Fn(&T) -> bool, T: ?Sized,
sourcepub fn fn_name(self, name: &'static str) -> Self
pub fn fn_name(self, name: &'static str) -> Self
Provide a descriptive name for this function.
Examples
use predicates::prelude::*;
struct Example {
string: String,
number: i32,
}
let string_check = predicate::function(|x: &Example| x.string == "hello")
.fn_name("is_hello");
println!("predicate: {}", string_check);
Trait Implementations§
source§impl<F, T> Clone for FnPredicate<F, T>where
F: Fn(&T) -> bool + Clone,
T: ?Sized + Clone,
impl<F, T> Clone for FnPredicate<F, T>where F: Fn(&T) -> bool + Clone, T: ?Sized + Clone,
source§fn clone(&self) -> FnPredicate<F, T>
fn clone(&self) -> FnPredicate<F, T>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<F, T> PartialEq<FnPredicate<F, T>> for FnPredicate<F, T>where
F: Fn(&T) -> bool + PartialEq,
T: ?Sized + PartialEq,
impl<F, T> PartialEq<FnPredicate<F, T>> for FnPredicate<F, T>where F: Fn(&T) -> bool + PartialEq, T: ?Sized + PartialEq,
source§fn eq(&self, other: &FnPredicate<F, T>) -> bool
fn eq(&self, other: &FnPredicate<F, T>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl<F, T> PredicateReflection for FnPredicate<F, T>where
F: Fn(&T) -> bool,
T: ?Sized,
impl<F, T> PredicateReflection for FnPredicate<F, T>where F: Fn(&T) -> bool, T: ?Sized,
impl<F, T> Copy for FnPredicate<F, T>where F: Fn(&T) -> bool + Copy, T: ?Sized + Copy,
impl<F, T> Eq for FnPredicate<F, T>where F: Fn(&T) -> bool + Eq, T: ?Sized + Eq,
impl<F, T> Send for FnPredicate<F, T>where F: Send + Fn(&T) -> bool, T: ?Sized,
impl<F, T> StructuralEq for FnPredicate<F, T>where F: Fn(&T) -> bool, T: ?Sized,
impl<F, T> StructuralPartialEq for FnPredicate<F, T>where F: Fn(&T) -> bool, T: ?Sized,
impl<F, T> Sync for FnPredicate<F, T>where F: Sync + Fn(&T) -> bool, T: ?Sized,
Auto Trait Implementations§
impl<F, T: ?Sized> RefUnwindSafe for FnPredicate<F, T>where F: RefUnwindSafe, T: RefUnwindSafe,
impl<F, T: ?Sized> Unpin for FnPredicate<F, T>where F: Unpin, T: Unpin,
impl<F, T: ?Sized> UnwindSafe for FnPredicate<F, T>where F: UnwindSafe, T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<P, Item> PredicateBooleanExt<Item> for Pwhere
P: Predicate<Item>,
Item: ?Sized,
impl<P, Item> PredicateBooleanExt<Item> for Pwhere P: Predicate<Item>, Item: ?Sized,
source§fn and<B>(self, other: B) -> AndPredicate<Self, B, Item>where
B: Predicate<Item>,
Self: Sized,
fn and<B>(self, other: B) -> AndPredicate<Self, B, Item>where B: Predicate<Item>, Self: Sized,
Compute the logical AND of two
Predicate
results, returning the result. Read moresource§impl<P, Item> PredicateBoxExt<Item> for Pwhere
P: Predicate<Item>,
impl<P, Item> PredicateBoxExt<Item> for Pwhere P: Predicate<Item>,
source§impl<P> PredicateFileContentExt for Pwhere
P: Predicate<[u8]>,
impl<P> PredicateFileContentExt for Pwhere P: Predicate<[u8]>,
source§fn from_file_path(self) -> FileContentPredicate<Self>
fn from_file_path(self) -> FileContentPredicate<Self>
source§impl<P, Item> PredicateNameExt<Item> for Pwhere
P: Predicate<Item>,
Item: ?Sized,
impl<P, Item> PredicateNameExt<Item> for Pwhere P: Predicate<Item>, Item: ?Sized,
source§impl<P> PredicateStrExt for Pwhere
P: Predicate<str>,
impl<P> PredicateStrExt for Pwhere P: Predicate<str>,
source§fn trim(self) -> TrimPredicate<Self>
fn trim(self) -> TrimPredicate<Self>
source§fn from_utf8(self) -> Utf8Predicate<Self>
fn from_utf8(self) -> Utf8Predicate<Self>
source§fn normalize(self) -> NormalizedPredicate<Self>
fn normalize(self) -> NormalizedPredicate<Self>
Returns a
NormalizedPredicate
that ensures
the newlines within the data passed to Self
is normalised. Read more