pub enum Sum<T, U> {
Left(T),
Right(U),
}Expand description
The ‘sum’ (or ‘either’) Resource Algebra.
This represents a resource that is in two possible states. Combining a Left with
a Right is invalid.
Variants§
Trait Implementations§
Source§impl<R1: RA, R2: RA, U: LocalUpdate<R1>> LocalUpdate<Sum<R1, R2>> for SumLocalUpdateL<U>
impl<R1: RA, R2: RA, U: LocalUpdate<R1>> LocalUpdate<Sum<R1, R2>> for SumLocalUpdateL<U>
Source§fn premise(self, from_auth: Sum<R1, R2>, from_frag: Sum<R1, R2>) -> bool
fn premise(self, from_auth: Sum<R1, R2>, from_frag: Sum<R1, R2>) -> bool
(open)
match (from_auth, from_frag) { (Sum::Left(from_auth), Sum::Left(from_frag)) => self.0.premise(from_auth, from_frag), (Sum::Right(_), Sum::Right(_)) => false, _ => true, }
Source§fn update(
self,
from_auth: Sum<R1, R2>,
from_frag: Sum<R1, R2>,
) -> (Sum<R1, R2>, Sum<R1, R2>)
fn update( self, from_auth: Sum<R1, R2>, from_frag: Sum<R1, R2>, ) -> (Sum<R1, R2>, Sum<R1, R2>)
(open)
match (from_auth, from_frag) { (Sum::Left(from_auth), Sum::Left(from_frag)) => { let (to_auth, to_frag) = self.0.update(from_auth, from_frag); (Sum::Left(to_auth), Sum::Left(to_frag)) } _ => such_that(|_| true), }
Source§fn frame_preserving(
self,
from_auth: Sum<R1, R2>,
from_frag: Sum<R1, R2>,
frame: Option<Sum<R1, R2>>,
)
fn frame_preserving( self, from_auth: Sum<R1, R2>, from_frag: Sum<R1, R2>, frame: Option<Sum<R1, R2>>, )
⚠
requires
self.premise(from_auth, from_frag)requires
Some(from_frag).op(frame) == Some(Some(from_auth))ensures
let (to_auth, to_frag) = self.update(from_auth, from_frag); Some(to_frag).op(frame) == Some(Some(to_auth))
Source§impl<R1: RA, R2: RA, U: LocalUpdate<R2>> LocalUpdate<Sum<R1, R2>> for SumLocalUpdateR<U>
impl<R1: RA, R2: RA, U: LocalUpdate<R2>> LocalUpdate<Sum<R1, R2>> for SumLocalUpdateR<U>
Source§fn premise(self, from_auth: Sum<R1, R2>, from_frag: Sum<R1, R2>) -> bool
fn premise(self, from_auth: Sum<R1, R2>, from_frag: Sum<R1, R2>) -> bool
(open)
match (from_auth, from_frag) { (Sum::Right(from_auth), Sum::Right(from_frag)) => self.0.premise(from_auth, from_frag), (Sum::Left(_), Sum::Left(_)) => false, _ => true, }
Source§fn update(
self,
from_auth: Sum<R1, R2>,
from_frag: Sum<R1, R2>,
) -> (Sum<R1, R2>, Sum<R1, R2>)
fn update( self, from_auth: Sum<R1, R2>, from_frag: Sum<R1, R2>, ) -> (Sum<R1, R2>, Sum<R1, R2>)
(open)
match (from_auth, from_frag) { (Sum::Right(from_auth), Sum::Right(from_frag)) => { let (to_auth, to_frag) = self.0.update(from_auth, from_frag); (Sum::Right(to_auth), Sum::Right(to_frag)) } _ => such_that(|_| true), }
Source§fn frame_preserving(
self,
from_auth: Sum<R1, R2>,
from_frag: Sum<R1, R2>,
frame: Option<Sum<R1, R2>>,
)
fn frame_preserving( self, from_auth: Sum<R1, R2>, from_frag: Sum<R1, R2>, frame: Option<Sum<R1, R2>>, )
⚠
requires
self.premise(from_auth, from_frag)requires
Some(from_frag).op(frame) == Some(Some(from_auth))ensures
let (to_auth, to_frag) = self.update(from_auth, from_frag); Some(to_frag).op(frame) == Some(Some(to_auth))
Source§impl<R1: RA, R2: RA> RA for Sum<R1, R2>
impl<R1: RA, R2: RA> RA for Sum<R1, R2>
Source§fn op(self, other: Self) -> Option<Self>
fn op(self, other: Self) -> Option<Self>
(open)
match (self, other) { (Self::Left(x), Self::Left(y)) => x.op(y).map_logic(|l| Self::Left(l)), (Self::Right(x), Self::Right(y)) => x.op(y).map_logic(|r| Self::Right(r)), _ => None, }
Source§fn factor(self, factor: Self) -> Option<Self>
fn factor(self, factor: Self) -> Option<Self>
(open)
match (self, factor) { (Self::Left(x), Self::Left(y)) => x.factor(y).map_logic(|l| Self::Left(l)), (Self::Right(x), Self::Right(y)) => x.factor(y).map_logic(|r| Self::Right(r)), _ => None, }
ensures
match result { Some(c) => factor.op(c) == Some(self), None => forall<c: Self> factor.op(c) != Some(self), }
Source§fn commutative(a: Self, b: Self)
fn commutative(a: Self, b: Self)
(open(pub(self)), law) ⚠
ensures
a.op(b) == b.op(a)Source§fn associative(a: Self, b: Self, c: Self)
fn associative(a: Self, b: Self, c: Self)
(open(pub(self)), law) ⚠
ensures
a.op(b).and_then_logic(|ab: Self| ab.op(c)) == b.op(c).and_then_logic(|bc| a.op(bc))
Source§fn core(self) -> Option<Self>
fn core(self) -> Option<Self>
(open)
match self { Self::Left(x) => x.core().map_logic(|l| Self::Left(l)), Self::Right(x) => x.core().map_logic(|r| Self::Right(r)), }
ensures
match result { Some(c) => c.op(c) == Some(c) && c.op(self) == Some(self), None => true }
Source§fn core_is_maximal_idemp(self, i: Self)
fn core_is_maximal_idemp(self, i: Self)
⚠
requires
i.op(i) == Some(i)requires
i.op(self) == Some(self)ensures
match self.core() { Some(c) => i.incl(c), None => false, }
Source§fn incl_eq(self, other: Self) -> bool
fn incl_eq(self, other: Self) -> bool
(open, sealed) Read more
Source§fn incl_eq_op(a: Self, b: Self, x: Self) -> bool
fn incl_eq_op(a: Self, b: Self, x: Self) -> bool
(open, sealed) Read more
Source§fn update_nondet(self, s: Set<Self>) -> bool
fn update_nondet(self, s: Set<Self>) -> bool
This is used in
Resource::update_nondet. Read moreSource§fn incl_transitive(a: Self, b: Self, c: Self)
fn incl_transitive(a: Self, b: Self, c: Self)
Source§impl<R1: RA, R2: RA, U: Update<R1>> Update<Sum<R1, R2>> for SumUpdateL<U>
impl<R1: RA, R2: RA, U: Update<R1>> Update<Sum<R1, R2>> for SumUpdateL<U>
Source§fn premise(self, from: Sum<R1, R2>) -> bool
fn premise(self, from: Sum<R1, R2>) -> bool
(open)
match from { Sum::Left(from) => self.0.premise(from), Sum::Right(_) => false, }
Source§fn update(self, from: Sum<R1, R2>, ch: U::Choice) -> Sum<R1, R2>
fn update(self, from: Sum<R1, R2>, ch: U::Choice) -> Sum<R1, R2>
(open)
match from { Sum::Left(from) => Sum::Left(self.0.update(from, ch)), x => x, /* Dummy */ }
requires
self.premise(from)Source§fn frame_preserving(self, from: Sum<R1, R2>, frame: Sum<R1, R2>) -> U::Choice
fn frame_preserving(self, from: Sum<R1, R2>, frame: Sum<R1, R2>) -> U::Choice
⚠
requires
self.premise(from)requires
from.op(frame) != Noneensures
self.update(from, result).op(frame) != Nonetype Choice = <U as Update<R1>>::Choice
Source§impl<R: RA, U: Update<R>, V: RA> Update<Sum<V, R>> for SumUpdateR<U>
impl<R: RA, U: Update<R>, V: RA> Update<Sum<V, R>> for SumUpdateR<U>
Source§fn premise(self, from: Sum<V, R>) -> bool
fn premise(self, from: Sum<V, R>) -> bool
(open)
match from { Sum::Right(from) => self.0.premise(from), Sum::Left(_) => false, }
Source§fn update(self, from: Sum<V, R>, ch: U::Choice) -> Sum<V, R>
fn update(self, from: Sum<V, R>, ch: U::Choice) -> Sum<V, R>
(open)
match from { Sum::Right(from) => Sum::Right(self.0.update(from, ch)), x => x, /* Dummy */ }
requires
self.premise(from)Source§fn frame_preserving(self, from: Sum<V, R>, frame: Sum<V, R>) -> U::Choice
fn frame_preserving(self, from: Sum<V, R>, frame: Sum<V, R>) -> U::Choice
⚠
requires
self.premise(from)requires
from.op(frame) != Noneensures
self.update(from, result).op(frame) != Nonetype Choice = <U as Update<R>>::Choice
Auto Trait Implementations§
impl<T, U> Freeze for Sum<T, U>
impl<T, U> RefUnwindSafe for Sum<T, U>where
T: RefUnwindSafe,
U: RefUnwindSafe,
impl<T, U> Send for Sum<T, U>
impl<T, U> Sync for Sum<T, U>
impl<T, U> Unpin for Sum<T, U>
impl<T, U> UnwindSafe for Sum<T, U>where
T: UnwindSafe,
U: 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