Struct entity::query::MapTypedPredicate [−][src]
Represents a typed Predicate
specifically for maps such as
std::collections::HashMap
, ensuring that only valid conditions are
used for a given type.
This is required due to limitations in Rust’s blanket impl functionality, which will be resolved once specialization is available.
Implementations
impl<T: ValueLike, C: IntoIterator<Item = (String, T)> + ValueLike> MapTypedPredicate<T, C>
[src]
pub fn new(predicate: Predicate) -> Self
[src]
Creates a new map typed predicate from an untyped predicate
pub fn as_untyped(&self) -> &Predicate
[src]
Returns a reference to the untyped Predicate
wrapped by this
typed instance
pub fn check(&self, value: C) -> bool
[src]
Checks if the typed predicate is satisfied by the given value
NOTE: This consumes the value instead of the untyped version that merely references the value
impl<T: ValueLike, C: IntoIterator<Item = (String, T)> + ValueLike> MapTypedPredicate<T, C>
[src]
pub fn any<P: Into<TypedPredicate<T>>>(p: P) -> Self
[src]
Creates a new typed predicate for Predicate::Any
Examples
use entity::{TypedPredicate as P, MapTypedPredicate as MP}; use std::collections::HashMap; let mut map = HashMap::new(); map.insert(String::from("a"), 1); map.insert(String::from("b"), 2); map.insert(String::from("c"), 3); let p = MP::any(P::equals(3)); assert_eq!(p.check(map.clone()), true); let p = MP::any(P::equals(4)); assert_eq!(p.check(map), false);
pub fn contains(value: T) -> Self
[src]
Creates a new typed predicate for Predicate::Contains
Examples
use entity::{TypedPredicate as P, MapTypedPredicate as MP}; use std::collections::HashMap; let mut map = HashMap::new(); map.insert(String::from("a"), 1); map.insert(String::from("b"), 2); map.insert(String::from("c"), 3); let p = MP::contains(3); assert_eq!(p.check(map.clone()), true); let p = MP::contains(4); assert_eq!(p.check(map), false);
pub fn contains_all<I: IntoIterator<Item = T>>(i: I) -> Self
[src]
Creates a new typed predicate for Predicate::ContainsAll
Examples
use entity::{TypedPredicate as P, MapTypedPredicate as MP}; use std::collections::HashMap; let mut map = HashMap::new(); map.insert(String::from("a"), 1); map.insert(String::from("b"), 2); map.insert(String::from("c"), 3); let p = MP::contains_all(vec![1, 3]); assert_eq!(p.check(map.clone()), true); let p = MP::contains_all(vec![1, 4]); assert_eq!(p.check(map), false);
pub fn contains_any<I: IntoIterator<Item = T>>(i: I) -> Self
[src]
Creates a new typed predicate for Predicate::ContainsAny
Examples
use entity::{TypedPredicate as P, MapTypedPredicate as MP}; use std::collections::HashMap; let mut map = HashMap::new(); map.insert(String::from("a"), 1); map.insert(String::from("b"), 2); map.insert(String::from("c"), 3); let p = MP::contains_any(vec![1, 4]); assert_eq!(p.check(map.clone()), true); let p = MP::contains_any(vec![4, 5]); assert_eq!(p.check(map), false);
Trait Implementations
impl<T: ValueLike, C: IntoIterator<Item = (String, T)> + ValueLike> BitAnd<MapTypedPredicate<T, C>> for MapTypedPredicate<T, C>
[src]
type Output = Self
The resulting type after applying the &
operator.
fn bitand(self, rhs: Self) -> Self
[src]
Shorthand to produce Predicate::And
impl<T: ValueLike, C: IntoIterator<Item = (String, T)> + ValueLike> BitOr<MapTypedPredicate<T, C>> for MapTypedPredicate<T, C>
[src]
type Output = Self
The resulting type after applying the |
operator.
fn bitor(self, rhs: Self) -> Self
[src]
Shorthand to produce Predicate::Or
impl<T: ValueLike, C: IntoIterator<Item = (String, T)> + ValueLike> BitXor<MapTypedPredicate<T, C>> for MapTypedPredicate<T, C>
[src]
type Output = Self
The resulting type after applying the ^
operator.
fn bitxor(self, rhs: Self) -> Self
[src]
Shorthand to produce Predicate::Xor
impl<T: Clone + ValueLike, C: Clone + IntoIterator<Item = (String, T)> + ValueLike> Clone for MapTypedPredicate<T, C>
[src]
fn clone(&self) -> MapTypedPredicate<T, C>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T: Debug + ValueLike, C: Debug + IntoIterator<Item = (String, T)> + ValueLike> Debug for MapTypedPredicate<T, C>
[src]
impl<T: ValueLike, C: IntoIterator<Item = (String, T)> + ValueLike> From<MapTypedPredicate<T, C>> for Predicate
[src]
fn from(map_typed_predicate: MapTypedPredicate<T, C>) -> Self
[src]
impl<T: ValueLike, C: IntoIterator<Item = (String, T)> + ValueLike> From<MapTypedPredicate<T, C>> for TypedPredicate<C>
[src]
fn from(map_typed_predicate: MapTypedPredicate<T, C>) -> Self
[src]
impl<T: ValueLike, C: IntoIterator<Item = (String, T)> + ValueLike> From<Predicate> for MapTypedPredicate<T, C>
[src]
impl<T: ValueLike, C: IntoIterator<Item = (String, T)> + ValueLike> From<TypedPredicate<C>> for MapTypedPredicate<T, C>
[src]
fn from(typed_predicate: TypedPredicate<C>) -> Self
[src]
impl<T: ValueLike, C: IntoIterator<Item = (String, T)> + ValueLike> Not for MapTypedPredicate<T, C>
[src]
type Output = Self
The resulting type after applying the !
operator.
fn not(self) -> Self::Output
[src]
Shorthand to produce Predicate::Not
impl<T: PartialEq + ValueLike, C: PartialEq + IntoIterator<Item = (String, T)> + ValueLike> PartialEq<MapTypedPredicate<T, C>> for MapTypedPredicate<T, C>
[src]
fn eq(&self, other: &MapTypedPredicate<T, C>) -> bool
[src]
fn ne(&self, other: &MapTypedPredicate<T, C>) -> bool
[src]
impl<T: ValueLike, C: IntoIterator<Item = (String, T)> + ValueLike> PartialEq<Predicate> for MapTypedPredicate<T, C>
[src]
fn eq(&self, other: &Predicate) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<T: ValueLike, C: IntoIterator<Item = (String, T)> + ValueLike> StructuralPartialEq for MapTypedPredicate<T, C>
[src]
Auto Trait Implementations
impl<T, C> !RefUnwindSafe for MapTypedPredicate<T, C>
impl<T, C> !Send for MapTypedPredicate<T, C>
impl<T, C> !Sync for MapTypedPredicate<T, C>
impl<T, C> Unpin for MapTypedPredicate<T, C> where
C: Unpin,
T: Unpin,
C: Unpin,
T: Unpin,
impl<T, C> !UnwindSafe for MapTypedPredicate<T, C>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DynClone for T where
T: Clone,
[src]
T: Clone,
pub fn __clone_box(&self, Private) -> *mut ()
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,