Struct SwitchTargets
pub struct SwitchTargets<'db> { /* private fields */ }Implementations§
§impl<'db> SwitchTargets<'db>
impl<'db> SwitchTargets<'db>
pub fn new(
targets: impl Iterator<Item = (u128, Idx<BasicBlock<'db>>)>,
otherwise: Idx<BasicBlock<'db>>,
) -> SwitchTargets<'db>
pub fn new( targets: impl Iterator<Item = (u128, Idx<BasicBlock<'db>>)>, otherwise: Idx<BasicBlock<'db>>, ) -> SwitchTargets<'db>
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<'db>>,
else_: Idx<BasicBlock<'db>>,
) -> SwitchTargets<'db>
pub fn static_if( value: u128, then: Idx<BasicBlock<'db>>, else_: Idx<BasicBlock<'db>>, ) -> SwitchTargets<'db>
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<'db>>
pub fn otherwise(&self) -> Idx<BasicBlock<'db>>
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<'db>>)>
pub fn iter(&self) -> impl Iterator<Item = (u128, Idx<BasicBlock<'db>>)>
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<'db>>]
pub fn all_targets(&self) -> &[Idx<BasicBlock<'db>>]
Returns a slice with all possible jump targets (including the fallback target).
pub fn target_for_value(&self, value: u128) -> Idx<BasicBlock<'db>>
pub fn target_for_value(&self, value: u128) -> Idx<BasicBlock<'db>>
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<'db> Clone for SwitchTargets<'db>
impl<'db> Clone for SwitchTargets<'db>
§fn clone(&self) -> SwitchTargets<'db>
fn clone(&self) -> SwitchTargets<'db>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl<'db> Debug for SwitchTargets<'db>
impl<'db> Debug for SwitchTargets<'db>
§impl<'db> Hash for SwitchTargets<'db>
impl<'db> Hash for SwitchTargets<'db>
§impl<'db> PartialEq for SwitchTargets<'db>
impl<'db> PartialEq for SwitchTargets<'db>
impl<'db> Eq for SwitchTargets<'db>
impl<'db> StructuralPartialEq for SwitchTargets<'db>
Auto Trait Implementations§
impl<'db> Freeze for SwitchTargets<'db>
impl<'db> RefUnwindSafe for SwitchTargets<'db>
impl<'db> Send for SwitchTargets<'db>
impl<'db> Sync for SwitchTargets<'db>
impl<'db> Unpin for SwitchTargets<'db>
impl<'db> UnwindSafe for SwitchTargets<'db>
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,
§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
§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<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<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