pub enum CountR {
Unit,
Auth(nat),
Token,
Tokens(nat),
Invalid,
}Expand description
A reference-counting PCM with authority and tokens.
Variants§
Unit
Unit element with no actual meaning.
Auth(nat)
Authority: tracks how many tokens have been minted
Token
Token: represents one reference
Tokens(nat)
Combination of tokens
Invalid
Invalid state
Implementations§
Source§impl CountR
impl CountR
pub fn arrow_0(self) -> nat
pub fn arrow_Auth_0(self) -> nat
pub fn arrow_Tokens_0(self) -> nat
Trait Implementations§
Source§impl PCM for CountR
impl PCM for CountR
Source§open spec fn op(self, other: Self) -> Self
open spec fn op(self, other: Self) -> Self
{
match (self, other) {
(CountR::Unit, x) | (x, CountR::Unit) => x,
(CountR::Token, CountR::Token) => CountR::Tokens(2),
(CountR::Token, CountR::Tokens(n)) | (CountR::Tokens(n), CountR::Token) => {
CountR::Tokens(n + 1)
}
(CountR::Tokens(n1), CountR::Tokens(n2)) => CountR::Tokens(n1 + n2),
(CountR::Auth(n), CountR::Token) | (CountR::Token, CountR::Auth(n)) => {
if n > 0 { CountR::Auth((n - 1) as nat) } else { CountR::Invalid }
}
(CountR::Auth(n), CountR::Tokens(m)) | (CountR::Tokens(m), CountR::Auth(n)) => {
if n >= m { CountR::Auth((n - m) as nat) } else { CountR::Invalid }
}
_ => CountR::Invalid,
}
}Source§proof fn closed_under_incl(a: Self, b: Self)
proof fn closed_under_incl(a: Self, b: Self)
Source§proof fn commutative(a: Self, b: Self)
proof fn commutative(a: Self, b: Self)
Source§proof fn associative(a: Self, b: Self, c: Self)
proof fn associative(a: Self, b: Self, c: Self)
Source§proof fn unit_valid()
proof fn unit_valid()
Auto Trait Implementations§
impl Freeze for CountR
impl RefUnwindSafe for CountR
impl Send for CountR
impl Sync for CountR
impl Unpin for CountR
impl UnwindSafe for CountR
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