pub struct Sigma<Raw: Debug, Invariant: Test<Raw, 1>> { /* private fields */ }Expand description
Type that maintains a given invariant.
Implementations§
Source§impl<Raw: Debug, Invariant: Test<Raw, 1>> Sigma<Raw, Invariant>
impl<Raw: Debug, Invariant: Test<Raw, 1>> Sigma<Raw, Invariant>
Sourcepub fn all<const N: usize>(array: &[Raw; N]) -> &[Sigma<Raw, Invariant>; N]
pub fn all<const N: usize>(array: &[Raw; N]) -> &[Sigma<Raw, Invariant>; N]
Check all elements of an array.
Sourcepub fn also<OtherInvariant: Test<Raw, 1>>(self) -> Sigma<Raw, OtherInvariant>
pub fn also<OtherInvariant: Test<Raw, 1>>(self) -> Sigma<Raw, OtherInvariant>
Without changing its internal value, view one sigma-typed value as implementing another sigma type by checking the latter invariant at runtime (iff debug assertions are enabled).
§Panics
If the latter invariant does not hold.
Sourcepub fn also_ref<OtherInvariant: Test<Raw, 1>>(
&self,
) -> &Sigma<Raw, OtherInvariant>
pub fn also_ref<OtherInvariant: Test<Raw, 1>>( &self, ) -> &Sigma<Raw, OtherInvariant>
Without changing its internal value, view one sigma-typed value as implementing another sigma type by checking the latter invariant at runtime (iff debug assertions are enabled).
§Panics
If the latter invariant does not hold.
Sourcepub fn check(&self)
pub fn check(&self)
Check an invariant if and only if debug assertions are enabled.
§Panics
If the invariant does not hold and debug assertions are enabled.
Sourcepub fn get(self) -> Raw
pub fn get(self) -> Raw
Unwrap the internal value that satisfies the invariant.
If you’re using this to create another value that should
also maintain an invariant, use map instead.
Sourcepub fn get_by<Y, F: FnOnce(Raw) -> Y>(self, f: F) -> Y
pub fn get_by<Y, F: FnOnce(Raw) -> Y>(self, f: F) -> Y
Unwrap the internal value that satisfies the invariant.
If you’re using this to create another value that should
also maintain an invariant, use map instead.
Sourcepub fn get_by_mut<Y, F: FnOnce(&mut Raw) -> Y>(&mut self, f: F) -> Y
pub fn get_by_mut<Y, F: FnOnce(&mut Raw) -> Y>(&mut self, f: F) -> Y
Unwrap the internal value that satisfies the invariant.
If you’re using this to create another value that should
also maintain an invariant, use map instead.
Sourcepub fn get_by_ref<Y, F: FnOnce(&Raw) -> Y>(&self, f: F) -> Y
pub fn get_by_ref<Y, F: FnOnce(&Raw) -> Y>(&self, f: F) -> Y
Unwrap the internal value that satisfies the invariant.
If you’re using this to create another value that should
also maintain an invariant, use map instead.
Sourcepub const fn get_mut(&mut self) -> &mut Raw
pub const fn get_mut(&mut self) -> &mut Raw
Unwrap the internal value that satisfies the invariant.
If you’re using this to create another value that should
also maintain an invariant, use map instead.
Sourcepub const fn get_ref(&self) -> &Raw
pub const fn get_ref(&self) -> &Raw
Unwrap the internal value that satisfies the invariant.
If you’re using this to create another value that should
also maintain an invariant, use map instead.
Sourcepub fn map<OtherRaw: Debug, OtherInvariant: Test<OtherRaw, 1>, F: FnOnce(Raw) -> OtherRaw>(
self,
f: F,
) -> Sigma<OtherRaw, OtherInvariant>
pub fn map<OtherRaw: Debug, OtherInvariant: Test<OtherRaw, 1>, F: FnOnce(Raw) -> OtherRaw>( self, f: F, ) -> Sigma<OtherRaw, OtherInvariant>
Apply a function to a term that implements a given invariant (say, A), then check the output for a (possibly different) invariant (say, B).
Sourcepub fn map_mut<Y, F: FnOnce(&mut Raw) -> Y>(&mut self, f: F) -> Y
pub fn map_mut<Y, F: FnOnce(&mut Raw) -> Y>(&mut self, f: F) -> Y
Apply a function that mutates this value, then check that the operation maintained this invariant.
Sourcepub fn map_ref<OtherRaw: Debug, OtherInvariant: Test<OtherRaw, 1>, F: FnOnce(&Raw) -> OtherRaw>(
&self,
f: F,
) -> Sigma<OtherRaw, OtherInvariant>
pub fn map_ref<OtherRaw: Debug, OtherInvariant: Test<OtherRaw, 1>, F: FnOnce(&Raw) -> OtherRaw>( &self, f: F, ) -> Sigma<OtherRaw, OtherInvariant>
Apply a function to a term that implements a given invariant (say, A), then check the output for a (possibly different) invariant (say, B).
Sourcepub fn new(raw: Raw) -> Self
pub fn new(raw: Raw) -> Self
Create a new sigma type instance by checking an invariant.
§Panics
If the invariant does not hold and debug assertions are enabled.
Sourcepub fn try_also<OtherInvariant: Test<Raw, 1>>(
self,
) -> Option<Sigma<Raw, OtherInvariant>>
pub fn try_also<OtherInvariant: Test<Raw, 1>>( self, ) -> Option<Sigma<Raw, OtherInvariant>>
Without changing its internal value, try to view one sigma-typed value as implementing another sigma type by checking the latter invariant at runtime.
§Errors
If the latter invariant does not hold.
Sourcepub fn try_also_ref<OtherInvariant: Test<Raw, 1>>(
&self,
) -> Result<&Sigma<Raw, OtherInvariant>, OtherInvariant::Error<'_>>
pub fn try_also_ref<OtherInvariant: Test<Raw, 1>>( &self, ) -> Result<&Sigma<Raw, OtherInvariant>, OtherInvariant::Error<'_>>
Without changing its internal value, try to view one sigma-typed value as implementing another sigma type by checking the latter invariant at runtime.
§Errors
If the latter invariant does not hold.
Trait Implementations§
Source§impl<L: Debug + Add<R, Output: Debug>, R: Debug, Invariant: Test<L, 1> + Test<R, 1> + Test<L::Output, 1>> Add<Sigma<R, Invariant>> for Sigma<L, Invariant>
impl<L: Debug + Add<R, Output: Debug>, R: Debug, Invariant: Test<L, 1> + Test<R, 1> + Test<L::Output, 1>> Add<Sigma<R, Invariant>> for Sigma<L, Invariant>
Source§impl<L: Debug + AddAssign<R>, R: Debug, Invariant: Test<L, 1> + Test<R, 1>> AddAssign<Sigma<R, Invariant>> for Sigma<L, Invariant>
impl<L: Debug + AddAssign<R>, R: Debug, Invariant: Test<L, 1> + Test<R, 1>> AddAssign<Sigma<R, Invariant>> for Sigma<L, Invariant>
Source§fn add_assign(&mut self, rhs: Sigma<R, Invariant>)
fn add_assign(&mut self, rhs: Sigma<R, Invariant>)
+= operation. Read moreSource§impl<Raw: CanBeInfinite + Debug, Invariant: Test<Raw>> CanBeInfinite for Sigma<Raw, Invariant>
impl<Raw: CanBeInfinite + Debug, Invariant: Test<Raw>> CanBeInfinite for Sigma<Raw, Invariant>
Source§fn check_finite(&self) -> bool
fn check_finite(&self) -> bool
NaN, etc).