pub struct StmtSwitch<'ast> {
pub selector: Expr<'ast>,
pub cases: &'ast mut RawThinSlice<(), StmtSwitchCase<'ast>>,
}Expand description
A Yul switch statement can consist of only a default-case or one or more non-default cases optionally followed by a default-case.
Example switch statement in Yul:
switch exponent
case 0 { result := 1 }
case 1 { result := base }
default { revert(0, 0) }Reference: https://docs.soliditylang.org/en/latest/grammar.html#a4.SolidityParser.yulSwitchStatement
Fields§
§selector: Expr<'ast>§cases: &'ast mut RawThinSlice<(), StmtSwitchCase<'ast>>The cases of the switch statement. Includes the default case in the last position, if any.
Implementations§
Source§impl<'ast> StmtSwitch<'ast>
impl<'ast> StmtSwitch<'ast>
Sourcepub fn default_case(&self) -> Option<&StmtSwitchCase<'ast>>
pub fn default_case(&self) -> Option<&StmtSwitchCase<'ast>>
Returns the default case of the switch statement, if any.
Trait Implementations§
Auto Trait Implementations§
impl<'ast> Freeze for StmtSwitch<'ast>
impl<'ast> RefUnwindSafe for StmtSwitch<'ast>
impl<'ast> Send for StmtSwitch<'ast>
impl<'ast> Sync for StmtSwitch<'ast>
impl<'ast> Unpin for StmtSwitch<'ast>
impl<'ast> !UnwindSafe for StmtSwitch<'ast>
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, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more