pub struct Sigma<Raw: Debug, Invariant: Test<Raw>> { /* private fields */ }Expand description
Type that maintains a given invariant.
Implementations§
Source§impl<Raw: Debug, Invariant: Test<Raw>> Sigma<Raw, Invariant>
impl<Raw: Debug, Invariant: Test<Raw>> Sigma<Raw, Invariant>
Sourcepub fn check(&self)
pub fn check(&self)
Create a new sigma type instance by checking 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 fn get_mut(&mut self) -> &mut Raw
pub 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 fn get_ref(&self) -> &Raw
pub 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>, F: FnOnce(Raw) -> OtherRaw>(
self,
f: F,
) -> Sigma<OtherRaw, OtherInvariant>
pub fn map<OtherRaw: Debug, OtherInvariant: Test<OtherRaw>, 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_ref<OtherRaw: Debug, OtherInvariant: Test<OtherRaw>, F: FnOnce(&Raw) -> OtherRaw>(
&self,
f: F,
) -> Sigma<OtherRaw, OtherInvariant>
pub fn map_ref<OtherRaw: Debug, OtherInvariant: Test<OtherRaw>, 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).