pub struct Frac<T> { /* private fields */ }Expand description
Token that maintains fractional access to some resource.
This allows multiple clients to obtain shared references to some resource
via borrow.
Implementations§
Source§impl<T> Frac<T>
impl<T> Frac<T>
Sourcepub open spec fn valid(self, id: Loc, frac: real) -> bool
pub open spec fn valid(self, id: Loc, frac: real) -> bool
{
&&& self.id() == id
&&& self.frac() == frac
}Sourcepub proof fn new(tracked v: T) -> tracked result : Self
pub proof fn new(tracked v: T) -> tracked result : Self
result.frac() == 1 as real,result.resource() == v,Create a fractional token that maintains shared access to the input resource.
Sourcepub proof fn agree(tracked &self, tracked other: &Self)
pub proof fn agree(tracked &self, tracked other: &Self)
self.id() == other.id(),ensuresself.resource() == other.resource(),Two tokens agree on values of the underlying resource.
Sourcepub proof fn split_to(tracked &mut self, result_frac: real) -> tracked result : Self
pub proof fn split_to(tracked &mut self, result_frac: real) -> tracked result : Self
(0 as real) < result_frac < old(self).frac(),ensuresself.id() == old(self).id(),result.id() == old(self).id(),self.resource() == old(self).resource(),result.resource() == old(self).resource(),self.frac() == old(self).frac() - result_frac,result.frac() == result_frac,Split one resource into two resources whose quantities sum to the original.
The returned token has quantity result_frac; the new value of the input token has
quantity old(self).frac() - result_frac.
Sourcepub proof fn split(tracked &mut self) -> tracked result : Self
pub proof fn split(tracked &mut self) -> tracked result : Self
self.id() == old(self).id(),result.id() == old(self).id(),self.resource() == old(self).resource(),result.resource() == old(self).resource(),self.frac() == old(self).frac() / 2 as real,result.frac() == old(self).frac() / 2 as real,Split one resource by half into two resources whose quantities sum to the original.
The returned token has quantity n; the new value of the input token has
quantity old(self).frac() - n.
Sourcepub proof fn combine(tracked &mut self, tracked other: Self)
pub proof fn combine(tracked &mut self, tracked other: Self)
old(self).id() == other.id(),ensuresself.id() == old(self).id(),self.resource() == old(self).resource(),self.resource() == other.resource(),self.frac() == old(self).frac() + other.frac(),Combine two tokens, summing their quantities.
Sourcepub proof fn bounded(tracked &self)
pub proof fn bounded(tracked &self)
(0 as real) < self.frac() <= (1 as real),Allowed values for a token’s quantity.
Sourcepub proof fn borrow(tracked &self) -> tracked ret : &T
pub proof fn borrow(tracked &self) -> tracked ret : &T
ret == self.resource(),Obtain shared access to the underlying resource.
Sourcepub proof fn take_resource(tracked self) -> tracked pair : (T, Empty<T>)
pub proof fn take_resource(tracked self) -> tracked pair : (T, Empty<T>)
self.frac() == 1 as real,ensurespair.0 == self.resource(),pair.1.id() == self.id(),Reclaim full ownership of the underlying resource.
Auto Trait Implementations§
impl<T> Freeze for Frac<T>
impl<T> RefUnwindSafe for Frac<T>where
T: RefUnwindSafe,
impl<T> Send for Frac<T>
impl<T> Sync for Frac<T>
impl<T> Unpin for Frac<T>where
T: Unpin,
impl<T> UnsafeUnpin for Frac<T>
impl<T> UnwindSafe for Frac<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, U> IntoSpecImpl<U> for Twhere
U: From<T>,
impl<T, U> IntoSpecImpl<U> for Twhere
U: From<T>,
Source§impl<T, VERUS_SPEC__A> TryFromSpec<T> for VERUS_SPEC__Awhere
VERUS_SPEC__A: TryFrom<T>,
impl<T, VERUS_SPEC__A> TryFromSpec<T> for VERUS_SPEC__Awhere
VERUS_SPEC__A: TryFrom<T>,
Source§exec fn obeys_try_from_spec() -> bool
exec fn obeys_try_from_spec() -> bool
Source§impl<T, VERUS_SPEC__A> TryIntoSpec<T> for VERUS_SPEC__Awhere
VERUS_SPEC__A: TryInto<T>,
impl<T, VERUS_SPEC__A> TryIntoSpec<T> for VERUS_SPEC__Awhere
VERUS_SPEC__A: TryInto<T>,
Source§exec fn obeys_try_into_spec() -> bool
exec fn obeys_try_into_spec() -> bool
Source§impl<T, U> TryIntoSpecImpl<U> for Twhere
U: TryFrom<T>,
impl<T, U> TryIntoSpecImpl<U> for Twhere
U: TryFrom<T>,
Source§open spec fn obeys_try_into_spec() -> bool
open spec fn obeys_try_into_spec() -> bool
{ <U as TryFromSpec<Self>>::obeys_try_from_spec() }