Struct hir_ty::mir::SwitchTargets
source · pub struct SwitchTargets { /* private fields */ }
Implementations§
source§impl SwitchTargets
impl SwitchTargets
sourcepub fn new(
targets: impl Iterator<Item = (u128, BasicBlockId)>,
otherwise: BasicBlockId,
) -> Self
pub fn new( targets: impl Iterator<Item = (u128, BasicBlockId)>, otherwise: BasicBlockId, ) -> Self
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: BasicBlockId, else_: BasicBlockId) -> Self
pub fn static_if(value: u128, then: BasicBlockId, else_: BasicBlockId) -> Self
Builds a switch targets definition that jumps to then
if the tested value equals value
,
and to else_
if not.
sourcepub fn otherwise(&self) -> BasicBlockId
pub fn otherwise(&self) -> BasicBlockId
Returns the fallback target that is jumped to when none of the values match the operand.
sourcepub fn iter(&self) -> impl Iterator<Item = (u128, BasicBlockId)> + '_
pub fn iter(&self) -> impl Iterator<Item = (u128, BasicBlockId)> + '_
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) -> &[BasicBlockId]
pub fn all_targets(&self) -> &[BasicBlockId]
Returns a slice with all possible jump targets (including the fallback target).
sourcepub fn target_for_value(&self, value: u128) -> BasicBlockId
pub fn target_for_value(&self, value: u128) -> BasicBlockId
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
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> 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