pub struct CountGhostResource<T, const TOTAL: usize> { /* private fields */ }Expand description
A struct that stores and dispatches CountGhost<T>.
Unlike CountGhost, it provides an empty state: after all fractions have been split out,
it still remembers the resource value inside the carrier, mirroring CountResource.
Implementations§
Source§impl<T, const TOTAL: usize> CountGhostResource<T, TOTAL>
impl<T, const TOTAL: usize> CountGhostResource<T, TOTAL>
Sourcepub open spec fn wf(self) -> bool
pub open spec fn wf(self) -> bool
{
&&& TOTAL > 0
&&& 0 <= self.frac() <= TOTAL
&&& self.type_inv()
}Type invariant.
Sourcepub open spec fn is_empty(self) -> bool
pub open spec fn is_empty(self) -> bool
{ self.frac() == 0 }Whether this CountGhostResource is empty, i.e., has no fraction.
Sourcepub open spec fn not_empty(self) -> bool
pub open spec fn not_empty(self) -> bool
{ !self.is_empty() }Whether the fraction stored in this CountGhostResource is less than TOTAL.
Sourcepub open spec fn is_full(self) -> bool
pub open spec fn is_full(self) -> bool
{ self.frac() == TOTAL }Whether this CountGhostResource has the full fraction, i.e., TOTAL.
Sourcepub closed spec fn view(self) -> T
pub closed spec fn view(self) -> T
Returns the value of type T stored in this CountGhostResource.
Sourcepub proof fn arbitrary() -> tracked res : Self
pub proof fn arbitrary() -> tracked res : Self
TOTAL > 0,Create an arbitrary CountGhostResource. Useful as a placeholder.
Sourcepub proof fn alloc(value: T) -> tracked res : Self
pub proof fn alloc(value: T) -> tracked res : Self
TOTAL > 0,ensuresres.not_empty(),res.is_full(),res@ == value,res.wf(),Allocates a new CountGhostResource with the full fraction and the given value.
Sourcepub proof fn split_one(tracked &mut self) -> tracked res : CountGhost<T, TOTAL>
pub proof fn split_one(tracked &mut self) -> tracked res : CountGhost<T, TOTAL>
old(self).not_empty(),ensuresfinal(self).id() == old(self).id(),final(self).frac() + 1 == old(self).frac(),final(self)@ == old(self)@,res.frac() == 1,res.id() == final(self).id(),res@ == final(self)@,!res.has_authority(),old(self).frac() == 1 ==> final(self).is_empty(),final(self).wf(),Splits a CountGhost with fraction 1.
Sourcepub proof fn split(tracked &mut self, n: int) -> tracked res : CountGhost<T, TOTAL>
pub proof fn split(tracked &mut self, n: int) -> tracked res : CountGhost<T, TOTAL>
1 <= n <= old(self).frac(),ensuresfinal(self).id() == old(self).id(),final(self).frac() + n == old(self).frac(),final(self)@ == old(self)@,res.frac() == n,res.id() == final(self).id(),res@ == final(self)@,!res.has_authority(),old(self).frac() == n ==> final(self).is_empty(),final(self).wf(),Splits a CountGhost with the given fraction.
Sourcepub proof fn combine(tracked &mut self, tracked other: CountGhost<T, TOTAL>)
pub proof fn combine(tracked &mut self, tracked other: CountGhost<T, TOTAL>)
old(self).id() == other.id(),ensuresold(self).frac() + other.frac() > TOTAL ==> false,old(self).frac() + other.frac() <= TOTAL
==> {
&&& final(self).id() == old(self).id()
&&& final(self)@ == old(self)@
&&& final(self)@ == other@
&&& final(self).frac() == old(self).frac() + other.frac()
&&& final(self).wf()
},Combines a CountGhost.
Sourcepub proof fn validate(tracked &self)
pub proof fn validate(tracked &self)
self.wf(),CountGhostResource satisfies the type invariant.
Sourcepub proof fn validate_with_frac(tracked &self, tracked frac: &CountGhost<T, TOTAL>)
pub proof fn validate_with_frac(tracked &self, tracked frac: &CountGhost<T, TOTAL>)
self.id() == frac.id(),ensuresself@ == frac@,A CountGhostResource and a CountGhost with the same id agree on the value.
Unlike CountGhost::agree, this works even when the resource is empty (all fractions split out).
Auto Trait Implementations§
impl<T, const TOTAL: usize> Freeze for CountGhostResource<T, TOTAL>
impl<T, const TOTAL: usize> RefUnwindSafe for CountGhostResource<T, TOTAL>where
T: RefUnwindSafe,
impl<T, const TOTAL: usize> Send for CountGhostResource<T, TOTAL>where
T: Send,
impl<T, const TOTAL: usize> Sync for CountGhostResource<T, TOTAL>where
T: Sync,
impl<T, const TOTAL: usize> Unpin for CountGhostResource<T, TOTAL>where
T: Unpin,
impl<T, const TOTAL: usize> UnsafeUnpin for CountGhostResource<T, TOTAL>
impl<T, const TOTAL: usize> UnwindSafe for CountGhostResource<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
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T, VERUS_SPEC__A> FromSpec<T> for VERUS_SPEC__Awhere
VERUS_SPEC__A: From<T>,
impl<T, VERUS_SPEC__A> FromSpec<T> for VERUS_SPEC__Awhere
VERUS_SPEC__A: From<T>,
fn obeys_from_spec() -> bool
fn from_spec(v: T) -> VERUS_SPEC__A
§impl<T, VERUS_SPEC__A> IntoSpec<T> for VERUS_SPEC__Awhere
VERUS_SPEC__A: Into<T>,
impl<T, VERUS_SPEC__A> IntoSpec<T> for VERUS_SPEC__Awhere
VERUS_SPEC__A: Into<T>,
fn obeys_into_spec() -> bool
fn into_spec(self) -> T
§impl<T, U> IntoSpecImpl<U> for Twhere
U: From<T>,
impl<T, U> IntoSpecImpl<U> for Twhere
U: From<T>,
fn obeys_into_spec() -> bool
fn into_spec(self) -> U
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.impl<A> SpecEq<&A> for Awhere
A: ?Sized,
impl<A> SpecEq<&mut A> for Awhere
A: ?Sized,
impl<A> SpecEq<A> for Awhere
A: ?Sized,
impl<A> SpecEq<Ghost<A>> for A
impl<A> SpecEq<Tracked<A>> for A
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.