Struct Invariant

Source
pub struct Invariant<T, F = Box<dyn FnMut(<T as ToOwned>::Owned) -> bool>>
where T: ToOwned + ?Sized,
{ /* private fields */ }

Implementations§

Source§

impl<T, F> Invariant<T, F>
where T: ToOwned,

Source

pub fn into_inner(self) -> T

Source§

impl<T, F> Invariant<T, F>
where T: ToOwned + ?Sized,

Source

pub fn as_inner_ref(&self) -> &T

Source§

impl<T, F> Invariant<T, F>
where T: ToOwned, F: FnMut(<T as ToOwned>::Owned) -> bool,

Source

pub fn try_from_inner(inner: T, check: F) -> Option<Self>

Source§

impl<T, F> Invariant<T, F>
where T: ToOwned, F: FnMut(<T as ToOwned>::Owned) -> bool, <T as ToOwned>::Owned: BorrowMut<T>,

Source

pub fn with_inner_mut<G, R>(&mut self, op: G) -> Option<R>
where G: FnOnce(&mut T) -> R,

Source

pub fn with_inner_mut_check<G, R>(&mut self, op: G) -> Option<R>
where G: FnOnce(&mut T, &mut F) -> R,

Source§

impl<T, F> Invariant<T, F>
where T: ToOwned + ?Sized, T::Owned: Clone, F: ToOwned,

Source

pub fn to_owned_inner(&self) -> Invariant<T::Owned, F::Owned>

Trait Implementations§

Source§

impl<U, T, F> AsRef<U> for Invariant<T, F>
where T: ToOwned + AsRef<U>,

Source§

fn as_ref(&self) -> &U

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

impl<T, F> Binary for Invariant<T, F>
where T: ToOwned + Binary + ?Sized,

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

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

impl<T, F> BuildHasher for Invariant<T, F>
where T: ToOwned + BuildHasher + ?Sized,

Source§

type Hasher = <T as BuildHasher>::Hasher

Type of the hasher that will be created.
Source§

fn build_hasher(&self) -> Self::Hasher

Creates a new hasher. Read more
1.71.0 · Source§

fn hash_one<T>(&self, x: T) -> u64
where T: Hash, Self: Sized, Self::Hasher: Hasher,

Calculates the hash of a single value. Read more
Source§

impl<T, F: Clone> Clone for Invariant<T, F>
where T: ToOwned + Clone + ?Sized,

Source§

fn clone(&self) -> Invariant<T, F>

Returns a copy 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, F: Debug> Debug for Invariant<T, F>
where T: ToOwned + Debug + ?Sized,

Source§

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

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

impl<T, F> Deref for Invariant<T, F>
where T: ToOwned + ?Sized,

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<T, F> Display for Invariant<T, F>
where T: ToOwned + Display + ?Sized,

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

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

impl<T, F: Debug + Any> Error for Invariant<T, F>
where T: ToOwned + Error + ?Sized,

Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl<T, F> Hash for Invariant<T, F>
where T: ToOwned + Hash + ?Sized,

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<Idx, T, F> Index<Idx> for Invariant<T, F>
where T: ToOwned + Index<Idx> + ?Sized,

Source§

type Output = <T as Index<Idx>>::Output

The returned type after indexing.
Source§

fn index(&self, index: Idx) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T, F> IntoIterator for Invariant<T, F>
where T: ToOwned + IntoIterator,

Source§

type Item = <T as IntoIterator>::Item

The type of the elements being iterated over.
Source§

type IntoIter = <T as IntoIterator>::IntoIter

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T, F> LowerExp for Invariant<T, F>
where T: ToOwned + LowerExp + ?Sized,

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

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

impl<T, F> LowerHex for Invariant<T, F>
where T: ToOwned + LowerHex + ?Sized,

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

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

impl<T, F> Octal for Invariant<T, F>
where T: ToOwned + Octal + ?Sized,

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

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

impl<T, F> Ord for Invariant<T, F>
where T: ToOwned + Ord + ?Sized,

Source§

fn cmp(&self, other: &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<U, T, G, F> PartialEq<Invariant<U, G>> for Invariant<T, F>
where U: ToOwned + ?Sized, T: ToOwned + PartialEq<U> + ?Sized,

Source§

fn eq(&self, other: &Invariant<U, G>) -> bool

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

fn ne(&self, other: &Invariant<U, G>) -> bool

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

impl<U, T, G, F> PartialOrd<Invariant<U, G>> for Invariant<T, F>
where U: ToOwned + ?Sized, T: ToOwned + PartialOrd<U> + ?Sized,

Source§

fn partial_cmp(&self, other: &Invariant<U, G>) -> Option<Ordering>

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

fn lt(&self, other: &Invariant<U, G>) -> bool

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

fn le(&self, other: &Invariant<U, G>) -> bool

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

fn gt(&self, other: &Invariant<U, G>) -> bool

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

fn ge(&self, other: &Invariant<U, G>) -> bool

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

impl<T, F> Pointer for Invariant<T, F>
where T: ToOwned + Pointer + ?Sized,

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

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

impl<T, F> ToSocketAddrs for Invariant<T, F>

Source§

type Iter = <T as ToSocketAddrs>::Iter

Returned iterator over socket addresses which this type may correspond to.
Source§

fn to_socket_addrs(&self) -> Result<Self::Iter>

Converts this object to an iterator of resolved SocketAddrs. Read more
Source§

impl<T, F> UpperExp for Invariant<T, F>
where T: ToOwned + UpperExp + ?Sized,

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

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

impl<T, F> UpperHex for Invariant<T, F>
where T: ToOwned + UpperHex + ?Sized,

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

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

impl<T, F: Copy> Copy for Invariant<T, F>
where T: ToOwned + Copy + ?Sized,

Source§

impl<T, F> Eq for Invariant<T, F>
where T: ToOwned + Eq + ?Sized,

Auto Trait Implementations§

§

impl<T, F> Freeze for Invariant<T, F>
where F: Freeze, T: Freeze + ?Sized,

§

impl<T, F> RefUnwindSafe for Invariant<T, F>

§

impl<T, F> Send for Invariant<T, F>
where F: Send, T: Send + ?Sized,

§

impl<T, F> Sync for Invariant<T, F>
where F: Sync, T: Sync + ?Sized,

§

impl<T, F> Unpin for Invariant<T, F>
where F: Unpin, T: Unpin + ?Sized,

§

impl<T, F> UnwindSafe for Invariant<T, F>
where F: UnwindSafe, T: UnwindSafe + ?Sized,

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.