Struct ra_ap_hir::mir::SwitchTargets
source · pub struct SwitchTargets { /* private fields */ }
Implementations§
source§impl SwitchTargets
impl SwitchTargets
sourcepub 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;
.
sourcepub 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.
sourcepub 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.
sourcepub 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.
sourcepub 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).
sourcepub 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§
source§impl Clone for SwitchTargets
impl Clone for SwitchTargets
source§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 moresource§impl Debug for SwitchTargets
impl Debug for SwitchTargets
source§impl Hash for SwitchTargets
impl Hash for SwitchTargets
source§impl PartialEq for SwitchTargets
impl PartialEq for SwitchTargets
source§fn eq(&self, other: &SwitchTargets) -> bool
fn eq(&self, other: &SwitchTargets) -> bool
self
and other
values to be equal, and is used
by ==
.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
source§impl<T> Cast for T
impl<T> Cast for T
source§fn cast<U>(self, interner: <U as HasInterner>::Interner) -> Uwhere
Self: CastTo<U>,
U: HasInterner,
fn cast<U>(self, interner: <U as HasInterner>::Interner) -> Uwhere
Self: CastTo<U>,
U: HasInterner,
U
using CastTo
.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.