Pet

Struct Pet 

Source
pub struct Pet<T, P>(/* private fields */);
Expand description

A value that is accepted by a given predicate.

Implementations§

Source§

impl<T, P: Pred<T>> Pet<T, P>

Source

pub fn new(t: T) -> Option<Self>

Attempts to create a new Pet<T, P> from a value t.

If P accepts t, then the result is a Some(..) containing the value t. Otherwise, None is returned.

Source

pub unsafe fn new_unchecked(t: T) -> Self

Creates a new Pet<T, P> from a value t without checking if P accepts t.

Source

pub fn value(self) -> T

Retrieves the value contained in this Pet<T, P>.

Trait Implementations§

Source§

impl<T, P> AsRef<T> for Pet<T, P>

Source§

fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T, P> Borrow<T> for Pet<T, P>

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T: Clone, P: Clone> Clone for Pet<T, P>

Source§

fn clone(&self) -> Pet<T, P>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T, P> Debug for Pet<T, P>
where T: Debug, P: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult

Formats the value using the given formatter. Read more
Source§

impl<'de, T, P: Pred<T>> Deserialize<'de> for Pet<T, P>
where T: Deserialize<'de>,

Available on crate feature serde only.
Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T, P> Display for Pet<T, P>
where T: Display,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult

Formats the value using the given formatter. Read more
Source§

impl<T, P> Hash for Pet<T, P>
where T: Hash,

Source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T, P> Ord for Pet<T, P>
where T: Ord,

Source§

fn cmp(&self, o: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T, P, Q> PartialEq<Pet<T, Q>> for Pet<T, P>
where T: PartialEq,

Source§

fn eq(&self, o: &Pet<T, Q>) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, o: &Pet<T, Q>) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T, P, Q> PartialOrd<Pet<T, Q>> for Pet<T, P>
where T: PartialOrd,

Source§

fn partial_cmp(&self, o: &Pet<T, Q>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
Source§

fn lt(&self, o: &Pet<T, Q>) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
Source§

fn le(&self, o: &Pet<T, Q>) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
Source§

fn gt(&self, o: &Pet<T, Q>) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
Source§

fn ge(&self, o: &Pet<T, Q>) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T, P: Pred<T>> Serialize for Pet<T, P>
where T: Serialize,

Available on crate feature serde only.
Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T: Copy, P: Copy> Copy for Pet<T, P>

Source§

impl<T, P> Eq for Pet<T, P>
where T: Eq,

Auto Trait Implementations§

§

impl<T, P> Freeze for Pet<T, P>
where T: Freeze, P: Freeze,

§

impl<T, P> RefUnwindSafe for Pet<T, P>

§

impl<T, P> Send for Pet<T, P>
where T: Send, P: Send,

§

impl<T, P> Sync for Pet<T, P>
where T: Sync, P: Sync,

§

impl<T, P> Unpin for Pet<T, P>
where T: Unpin, P: Unpin,

§

impl<T, P> UnwindSafe for Pet<T, P>
where T: UnwindSafe, P: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,