pub enum Sum<A, B> {
Inl(A),
Inr(B),
}Expand description
The sum type.
Variants§
Implementations§
Source§impl<A, B> Sum<A, B>
impl<A, B> Sum<A, B>
pub fn arrow_Inl_0(self) -> A
pub fn arrow_Inr_0(self) -> B
Trait Implementations§
Source§impl<A: Consistency, B: Consistency> Consistency for Sum<A, B>
impl<A: Consistency, B: Consistency> Consistency for Sum<A, B>
Source§open spec fn consistent(&self, v: Self::Val) -> bool
open spec fn consistent(&self, v: Self::Val) -> bool
{
match (self, v) {
(Sum::Inl(a), Sum::Inl(va)) => a.consistent(va),
(Sum::Inr(b), Sum::Inr(vb)) => b.consistent(vb),
_ => false,
}
}Source§type Val = Sum<<A as Consistency>::Val, <B as Consistency>::Val>
type Val = Sum<<A as Consistency>::Val, <B as Consistency>::Val>
The type of values whose consistency is being checked.
Source§impl<A, B, TA, TB> DerOrd<Sum<TA, TB>> for Choice<A, B>
impl<A, B, TA, TB> DerOrd<Sum<TA, TB>> for Choice<A, B>
Source§proof fn lemma_der_serialize_len(&self, value: Sum<TA::V, TB::V>)
proof fn lemma_der_serialize_len(&self, value: Sum<TA::V, TB::V>)
Source§open spec fn der_remaining(
&self,
value: Sum<TA::V, TB::V>,
state: ChoiceDerState<A::State, B::State>,
) -> Seq<u8>
open spec fn der_remaining( &self, value: Sum<TA::V, TB::V>, state: ChoiceDerState<A::State, B::State>, ) -> Seq<u8>
{
match (value, state) {
(Sum::Inl(value), ChoiceDerState::Left(state)) => {
self.0.der_remaining(value, state)
}
(Sum::Inr(value), ChoiceDerState::Right(state)) => {
self.1.der_remaining(value, state)
}
_ => Seq::empty(),
}
}Source§open spec fn der_state_valid(
&self,
value: Sum<TA::V, TB::V>,
state: ChoiceDerState<A::State, B::State>,
) -> bool
open spec fn der_state_valid( &self, value: Sum<TA::V, TB::V>, state: ChoiceDerState<A::State, B::State>, ) -> bool
{
match (value, state) {
(Sum::Inl(value), ChoiceDerState::Left(state)) => {
self.0.der_state_valid(value, state)
}
(Sum::Inr(value), ChoiceDerState::Right(state)) => {
self.1.der_state_valid(value, state)
}
_ => false,
}
}Source§impl<A, B> EquivSerializers for Sum<A, B>where
A: EquivSerializers,
B: EquivSerializers,
impl<A, B> EquivSerializers for Sum<A, B>where
A: EquivSerializers,
B: EquivSerializers,
Source§impl<A, B> EquivSerializersGeneral for Sum<A, B>where
A: EquivSerializersGeneral,
B: EquivSerializersGeneral,
impl<A, B> EquivSerializersGeneral for Sum<A, B>where
A: EquivSerializersGeneral,
B: EquivSerializersGeneral,
Source§open spec fn equiv_general_inv(&self) -> bool
open spec fn equiv_general_inv(&self) -> bool
{
match self {
Sum::Inl(a) => a.equiv_general_inv(),
Sum::Inr(b) => b.equiv_general_inv(),
}
}Source§proof fn lemma_serialize_equiv(&self, v: Self::SVal, obuf: Seq<u8>)
proof fn lemma_serialize_equiv(&self, v: Self::SVal, obuf: Seq<u8>)
Source§impl<A: GoodSerializer, B: GoodSerializer> GoodSerializer for Sum<A, B>
impl<A: GoodSerializer, B: GoodSerializer> GoodSerializer for Sum<A, B>
Source§open spec fn serialize_inv(&self) -> bool
open spec fn serialize_inv(&self) -> bool
{
match self {
Sum::Inl(a) => a.serialize_inv(),
Sum::Inr(b) => b.serialize_inv(),
}
}Source§proof fn lemma_serialize_len(&self, v: Self::SVal)
proof fn lemma_serialize_len(&self, v: Self::SVal)
Source§impl<A: MinMaxByteLen, B: MinMaxByteLen> MinMaxByteLen for Sum<A, B>
impl<A: MinMaxByteLen, B: MinMaxByteLen> MinMaxByteLen for Sum<A, B>
Source§impl<A: NoLookAhead, B: NoLookAhead> NoLookAhead for Sum<A, B>
impl<A: NoLookAhead, B: NoLookAhead> NoLookAhead for Sum<A, B>
Source§open spec fn no_lookahead_inv(&self) -> bool
open spec fn no_lookahead_inv(&self) -> bool
{
match self {
Sum::Inl(a) => a.no_lookahead_inv(),
Sum::Inr(b) => b.no_lookahead_inv(),
}
}Source§proof fn lemma_no_lookahead(&self, i1: Seq<u8>, i2: Seq<u8>)
proof fn lemma_no_lookahead(&self, i1: Seq<u8>, i2: Seq<u8>)
Source§impl<A: NonMalleable, B: NonMalleable> NonMalleable for Sum<A, B>
impl<A: NonMalleable, B: NonMalleable> NonMalleable for Sum<A, B>
Source§open spec fn nonmal_inv(&self) -> bool
open spec fn nonmal_inv(&self) -> bool
{
match self {
Sum::Inl(a) => a.nonmal_inv(),
Sum::Inr(b) => b.nonmal_inv(),
}
}Source§proof fn lemma_parse_non_malleable(&self, buf1: Seq<u8>, buf2: Seq<u8>)
proof fn lemma_parse_non_malleable(&self, buf1: Seq<u8>, buf2: Seq<u8>)
Source§impl<A, B> NonTailFmt for Sum<A, B>where
A: NonTailFmt,
B: NonTailFmt,
impl<A, B> NonTailFmt for Sum<A, B>where
A: NonTailFmt,
B: NonTailFmt,
Source§open spec fn serialize_dps_inv(&self) -> bool
open spec fn serialize_dps_inv(&self) -> bool
{
match self {
Sum::Inl(a) => a.serialize_dps_inv(),
Sum::Inr(b) => b.serialize_dps_inv(),
}
}Source§proof fn lemma_serialize_dps_prepend(&self, v: Self::SValue, obuf: Seq<u8>)
proof fn lemma_serialize_dps_prepend(&self, v: Self::SValue, obuf: Seq<u8>)
Source§proof fn lemma_serialize_dps_len(&self, v: Self::SValue, obuf: Seq<u8>)
proof fn lemma_serialize_dps_len(&self, v: Self::SValue, obuf: Seq<u8>)
Source§impl<A: Productive, B: Productive> Productive for Sum<A, B>
impl<A: Productive, B: Productive> Productive for Sum<A, B>
Source§open spec fn productive_inv(&self) -> bool
open spec fn productive_inv(&self) -> bool
{
match self {
Sum::Inl(a) => a.productive_inv(),
Sum::Inr(b) => b.productive_inv(),
}
}Source§proof fn lemma_productive(&self, s: Seq<u8>)
proof fn lemma_productive(&self, s: Seq<u8>)
Source§impl<A: SPRoundTripDps, B: SPRoundTripDps> SPRoundTripDps for Sum<A, B>
impl<A: SPRoundTripDps, B: SPRoundTripDps> SPRoundTripDps for Sum<A, B>
Source§open spec fn unambiguous(&self) -> bool
open spec fn unambiguous(&self) -> bool
{
match self {
Sum::Inl(a) => a.unambiguous(),
Sum::Inr(b) => b.unambiguous(),
}
}Source§proof fn theorem_serialize_dps_parse_roundtrip(&self, v: Self::T, obuf: Seq<u8>)
proof fn theorem_serialize_dps_parse_roundtrip(&self, v: Self::T, obuf: Seq<u8>)
Source§impl<A: SafeParser, B: SafeParser> SafeParser for Sum<A, B>
impl<A: SafeParser, B: SafeParser> SafeParser for Sum<A, B>
Source§impl<Output: OutputBuf, A, B, TA, TB> Serializer<Output, Sum<TA, TB>> for Choice<A, B>where
TA: DeepView,
TB: DeepView,
A: Serializer<Output, TA>,
B: Serializer<Output, TB>,
impl<Output: OutputBuf, A, B, TA, TB> Serializer<Output, Sum<TA, TB>> for Choice<A, B>where
TA: DeepView,
TB: DeepView,
A: Serializer<Output, TA>,
B: Serializer<Output, TB>,
Source§exec fn serialize_into(&self, v: &Sum<TA, TB>, obuf: &mut Output)
exec fn serialize_into(&self, v: &Sum<TA, TB>, obuf: &mut Output)
Source§impl<Output: OutputBuf, A, B, TA, TB> Serializer<Output, Sum<TA, TB>> for Sum<A, B>where
TA: DeepView,
TB: DeepView,
A: Serializer<Output, TA>,
B: Serializer<Output, TB>,
impl<Output: OutputBuf, A, B, TA, TB> Serializer<Output, Sum<TA, TB>> for Sum<A, B>where
TA: DeepView,
TB: DeepView,
A: Serializer<Output, TA>,
B: Serializer<Output, TB>,
Source§open spec fn exec_inv(&self) -> bool
open spec fn exec_inv(&self) -> bool
{
match self {
super::Sum::Inl(a) => a.exec_inv(),
super::Sum::Inr(b) => b.exec_inv(),
}
}Source§exec fn serialize_into(&self, v: &Sum<TA, TB>, obuf: &mut Output)
exec fn serialize_into(&self, v: &Sum<TA, TB>, obuf: &mut Output)
Source§impl<A: SoundParser, B: SoundParser> SoundParser for Sum<A, B>
impl<A: SoundParser, B: SoundParser> SoundParser for Sum<A, B>
Source§impl<A, B> SpecByteLen for Sum<A, B>where
A: SpecByteLen,
B: SpecByteLen,
impl<A, B> SpecByteLen for Sum<A, B>where
A: SpecByteLen,
B: SpecByteLen,
Source§open spec fn byte_len(&self, v: Self::T) -> nat
open spec fn byte_len(&self, v: Self::T) -> nat
{
match (self, v) {
(Sum::Inl(a), Sum::Inl(va)) => a.byte_len(va),
(Sum::Inr(b), Sum::Inr(vb)) => b.byte_len(vb),
_ => 0,
}
}Source§type T = Sum<<A as SpecByteLen>::T, <B as SpecByteLen>::T>
type T = Sum<<A as SpecByteLen>::T, <B as SpecByteLen>::T>
The type of values whose byte length is being computed.
Source§impl<A: SpecParser, B: SpecParser> SpecParser for Sum<A, B>
impl<A: SpecParser, B: SpecParser> SpecParser for Sum<A, B>
Source§open spec fn spec_parse(&self, ibuf: Seq<u8>) -> Option<(int, Self::PVal)>
open spec fn spec_parse(&self, ibuf: Seq<u8>) -> Option<(int, Self::PVal)>
{
match self {
Sum::Inl(a) => {
match a.spec_parse(ibuf) {
Some((n, va)) => Some((n, Sum::Inl(va))),
None => None,
}
}
Sum::Inr(b) => {
match b.spec_parse(ibuf) {
Some((n, vb)) => Some((n, Sum::Inr(vb))),
None => None,
}
}
}
}Source§type PVal = Sum<<A as SpecParser>::PVal, <B as SpecParser>::PVal>
type PVal = Sum<<A as SpecParser>::PVal, <B as SpecParser>::PVal>
The type of parsed values.
Source§impl<A, B> SpecSerializer for Sum<A, B>where
A: SpecSerializer,
B: SpecSerializer,
impl<A, B> SpecSerializer for Sum<A, B>where
A: SpecSerializer,
B: SpecSerializer,
Source§open spec fn spec_serialize(&self, v: Self::SVal) -> Seq<u8>
open spec fn spec_serialize(&self, v: Self::SVal) -> Seq<u8>
{
match (self, v) {
(Sum::Inl(a), Sum::Inl(va)) => a.spec_serialize(va),
(Sum::Inr(b), Sum::Inr(vb)) => b.spec_serialize(vb),
_ => Seq::empty(),
}
}Source§type SVal = Sum<<A as SpecSerializer>::SVal, <B as SpecSerializer>::SVal>
type SVal = Sum<<A as SpecSerializer>::SVal, <B as SpecSerializer>::SVal>
The type of values to be serialized.
Source§impl<A, B> SpecSerializerDps for Sum<A, B>where
A: SpecSerializerDps,
B: SpecSerializerDps,
impl<A, B> SpecSerializerDps for Sum<A, B>where
A: SpecSerializerDps,
B: SpecSerializerDps,
Source§open spec fn spec_serialize_dps(&self, v: Self::SValue, obuf: Seq<u8>) -> Seq<u8>
open spec fn spec_serialize_dps(&self, v: Self::SValue, obuf: Seq<u8>) -> Seq<u8>
{
match (self, v) {
(Sum::Inl(a), Sum::Inl(va)) => a.spec_serialize_dps(va, obuf),
(Sum::Inr(b), Sum::Inr(vb)) => b.spec_serialize_dps(vb, obuf),
_ => obuf,
}
}Source§type SValue = Sum<<A as SpecSerializerDps>::SValue, <B as SpecSerializerDps>::SValue>
type SValue = Sum<<A as SpecSerializerDps>::SValue, <B as SpecSerializerDps>::SValue>
The type of values to be serialized.
Source§impl<A: ValueByteLen, B: ValueByteLen> ValueByteLen for Sum<A, B>
impl<A: ValueByteLen, B: ValueByteLen> ValueByteLen for Sum<A, B>
Source§open spec fn value_byte_len(v: Self::T) -> nat
open spec fn value_byte_len(v: Self::T) -> nat
{
match v {
Sum::Inl(va) => A::value_byte_len(va),
Sum::Inr(vb) => B::value_byte_len(vb),
}
}Source§proof fn lemma_value_len_matches_byte_len(&self, v: Self::T)
proof fn lemma_value_len_matches_byte_len(&self, v: Self::T)
impl<A: Copy, B: Copy> Copy for Sum<A, B>
impl<A: Eq, B: Eq> Eq for Sum<A, B>
impl<A, B> StructuralPartialEq for Sum<A, B>
Auto Trait Implementations§
impl<A, B> Freeze for Sum<A, B>
impl<A, B> RefUnwindSafe for Sum<A, B>where
A: RefUnwindSafe,
B: RefUnwindSafe,
impl<A, B> Send for Sum<A, B>
impl<A, B> Sync for Sum<A, B>
impl<A, B> Unpin for Sum<A, B>
impl<A, B> UnsafeUnpin for Sum<A, B>where
A: UnsafeUnpin,
B: UnsafeUnpin,
impl<A, B> UnwindSafe for Sum<A, B>where
A: UnwindSafe,
B: 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<VERUS_SPEC__A> DebugSpec for VERUS_SPEC__A
impl<VERUS_SPEC__A> DebugSpec for VERUS_SPEC__A
§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
Source§impl<C> NonAmbiguous for Cwhere
C: SPRoundTrip,
impl<C> NonAmbiguous for Cwhere
C: SPRoundTrip,
Source§open spec fn nonamb_inv(&self) -> bool
open spec fn nonamb_inv(&self) -> bool
{ self.sp_roundtrip_inv() }Source§proof fn lemma_serialize_injective(
&self,
v1: <C as Consistency>::Val,
v2: <C as Consistency>::Val,
)
proof fn lemma_serialize_injective( &self, v1: <C as Consistency>::Val, v2: <C as Consistency>::Val, )
Source§impl<C> PSRoundTrip for C
impl<C> PSRoundTrip for C
Source§open spec fn ps_roundtrip_inv(&self) -> bool
open spec fn ps_roundtrip_inv(&self) -> bool
{ self.safe_inv() && self.sound_inv() && self.nonmal_inv() && self.sp_roundtrip_inv() }Source§proof fn theorem_parse_serialize_roundtrip(&self, ibuf: Seq<u8>)
proof fn theorem_parse_serialize_roundtrip(&self, ibuf: Seq<u8>)
§impl<A, Rhs> PartialEqIs<Rhs> for A
impl<A, Rhs> PartialEqIs<Rhs> for A
§impl<Rhs, VERUS_SPEC__A> PartialEqSpec<Rhs> for VERUS_SPEC__A
impl<Rhs, VERUS_SPEC__A> PartialEqSpec<Rhs> for VERUS_SPEC__A
Source§impl<C> SPRoundTrip for C
impl<C> SPRoundTrip for C
Source§open spec fn sp_roundtrip_inv(&self) -> bool
open spec fn sp_roundtrip_inv(&self) -> bool
{ self.serialize_inv() && self.equiv_inv() && self.unambiguous() }