Struct hir::mir::SwitchTargets
pub struct SwitchTargets { /* private fields */ }
Implementations§
§impl SwitchTargets
impl SwitchTargets
pub fn new(
targets: impl Iterator<Item = (u128, Idx<BasicBlock>)>,
otherwise: Idx<BasicBlock>,
) -> SwitchTargets
pub fn new( targets: impl Iterator<Item = (u128, Idx<BasicBlock>)>, otherwise: Idx<BasicBlock>, ) -> SwitchTargets
Creates switch targets from an iterator of values and target blocks.
The iterator may be empty, in which case the SwitchInt
instruction is equivalent to
goto otherwise;
.
pub fn static_if(
value: u128,
then: Idx<BasicBlock>,
else_: Idx<BasicBlock>,
) -> SwitchTargets
pub fn static_if( value: u128, then: Idx<BasicBlock>, else_: Idx<BasicBlock>, ) -> SwitchTargets
Builds a switch targets definition that jumps to then
if the tested value equals value
,
and to else_
if not.
pub fn otherwise(&self) -> Idx<BasicBlock>
pub fn otherwise(&self) -> Idx<BasicBlock>
Returns the fallback target that is jumped to when none of the values match the operand.
pub fn iter(&self) -> impl Iterator<Item = (u128, Idx<BasicBlock>)>
pub fn iter(&self) -> impl Iterator<Item = (u128, Idx<BasicBlock>)>
Returns an iterator over the switch targets.
The iterator will yield tuples containing the value and corresponding target to jump to, not
including the otherwise
fallback target.
Note that this may yield 0 elements. Only the otherwise
branch is mandatory.
pub fn all_targets(&self) -> &[Idx<BasicBlock>]
pub fn all_targets(&self) -> &[Idx<BasicBlock>]
Returns a slice with all possible jump targets (including the fallback target).
pub fn target_for_value(&self, value: u128) -> Idx<BasicBlock>
pub fn target_for_value(&self, value: u128) -> Idx<BasicBlock>
Finds the BasicBlock
to which this SwitchInt
will branch given the
specific value. This cannot fail, as it’ll return the otherwise
branch if there’s not a specific match for the value.
Trait Implementations§
§impl Clone for SwitchTargets
impl Clone for SwitchTargets
§fn clone(&self) -> SwitchTargets
fn clone(&self) -> SwitchTargets
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl Debug for SwitchTargets
impl Debug for SwitchTargets
§impl Hash for SwitchTargets
impl Hash for SwitchTargets
§impl PartialEq for SwitchTargets
impl PartialEq for SwitchTargets
impl Eq for SwitchTargets
impl StructuralPartialEq for SwitchTargets
Auto Trait Implementations§
impl Freeze for SwitchTargets
impl RefUnwindSafe for SwitchTargets
impl Send for SwitchTargets
impl Sync for SwitchTargets
impl Unpin for SwitchTargets
impl UnwindSafe for SwitchTargets
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> Cast for T
impl<T> Cast for T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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>
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