pub struct CountGhost<T, const TOTAL: usize = 2> { /* private fields */ }Implementations§
Source§impl<T, const TOTAL: usize> CountGhost<T, TOTAL>
impl<T, const TOTAL: usize> CountGhost<T, TOTAL>
Whether this token carries the authority for updating the resource value.
Sourcepub open spec fn valid(self, id: Loc, frac: int) -> bool
pub open spec fn valid(self, id: Loc, frac: int) -> bool
{
&&& self.id() == id
&&& self.frac() == frac
}Sourcepub proof fn alloc(v: T) -> tracked result : Self
pub proof fn alloc(v: T) -> tracked result : Self
requires
TOTAL > 0,ensuresresult.frac() == TOTAL,result@ == v,result.has_authority(),Allocates a new CountGhost with the full fraction, the given value, and the authority.
Sourcepub proof fn agree(tracked &self, tracked other: &Self)
pub proof fn agree(tracked &self, tracked other: &Self)
requires
self.id() == other.id(),ensuresself@ == other@,Two CountGhosts with the same id must have the same resource value.
Sourcepub proof fn split(tracked &mut self, n: int) -> tracked result : Self
pub proof fn split(tracked &mut self, n: int) -> tracked result : Self
requires
0 < n < old(self).frac(),ensuresresult.id() == final(self).id(),final(self).id() == old(self).id(),final(self)@ == old(self)@,result@ == old(self)@,final(self).frac() + result.frac() == old(self).frac(),result.frac() == n,!result.has_authority(),final(self).has_authority() == old(self).has_authority(),Splits another fraction n from this CountGhost, returning a new CountGhost with
that fraction.
Sourcepub proof fn combine(tracked &mut self, tracked other: Self)
pub proof fn combine(tracked &mut self, tracked other: Self)
requires
old(self).id() == other.id(),ensuresfinal(self).id() == old(self).id(),final(self)@ == old(self)@,final(self)@ == other@,final(self).frac() == old(self).frac() + other.frac(),final(self).has_authority() == (old(self).has_authority() || other.has_authority()),Combines a CountGhost.
Sourcepub proof fn update(tracked &mut self, v: T)
pub proof fn update(tracked &mut self, v: T)
requires
old(self).has_authority(),old(self).frac() == TOTAL,ensuresfinal(self).id() == old(self).id(),final(self)@ == v,final(self).frac() == old(self).frac(),final(self).has_authority(),Updates the value stored in this CountGhost.
The token must be the authority and hold the full fraction.
Sourcepub proof fn update_with(tracked &mut self, tracked other: &mut Self, v: T)
pub proof fn update_with(tracked &mut self, tracked other: &mut Self, v: T)
requires
old(self).id() == old(other).id(),old(self).frac() + old(other).frac() == TOTAL,old(self).has_authority() || old(other).has_authority(),ensuresfinal(self).id() == old(self).id(),final(other).id() == old(other).id(),final(self).frac() == old(self).frac(),final(other).frac() == old(other).frac(),old(self)@ == old(other)@,final(self)@ == v,final(other)@ == v,Updates the value stored in both CountGhosts.
Auto Trait Implementations§
impl<T, const TOTAL: usize> Freeze for CountGhost<T, TOTAL>
impl<T, const TOTAL: usize> RefUnwindSafe for CountGhost<T, TOTAL>where
T: RefUnwindSafe,
impl<T, const TOTAL: usize> Send for CountGhost<T, TOTAL>where
T: Send,
impl<T, const TOTAL: usize> Sync for CountGhost<T, TOTAL>where
T: Sync,
impl<T, const TOTAL: usize> Unpin for CountGhost<T, TOTAL>where
T: Unpin,
impl<T, const TOTAL: usize> UnsafeUnpin for CountGhost<T, TOTAL>
impl<T, const TOTAL: usize> UnwindSafe for CountGhost<T, TOTAL>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
Mutably borrows from an owned value. Read more