[−][src]Struct rustc_middle::mir::terminator::SwitchTargets

pub struct SwitchTargets {
    values: SmallVec<[u128; 1]>,
    targets: SmallVec<[BasicBlock; 2]>,
}

Fields

values: SmallVec<[u128; 1]>

Possible values. The locations to branch to in each case are found in the corresponding indices from the targets vector.

targets: SmallVec<[BasicBlock; 2]>

Possible branch sites. The last element of this vector is used for the otherwise branch, so targets.len() == values.len() + 1 should hold.

Implementations

impl SwitchTargets[src]

pub fn new(
    targets: impl Iterator<Item = (u128, BasicBlock)>,
    otherwise: BasicBlock
) -> Self
[src]

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: BasicBlock, else_: BasicBlock) -> Self[src]

Builds a switch targets definition that jumps to then if the tested value equals value, and to else_ if not.

pub fn otherwise(&self) -> BasicBlock[src]

Returns the fallback target that is jumped to when none of the values match the operand.

pub fn iter(&self) -> SwitchTargetsIter<'_>ⓘ

Notable traits for SwitchTargetsIter<'a>

impl<'a> Iterator for SwitchTargetsIter<'a> type Item = (u128, BasicBlock);
[src]

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) -> &[BasicBlock][src]

Returns a slice with all possible jump targets (including the fallback target).

pub fn all_targets_mut(&mut self) -> &mut [BasicBlock][src]

Trait Implementations

impl Clone for SwitchTargets[src]

impl Debug for SwitchTargets[src]

impl<'tcx, __D: TyDecoder<'tcx>> Decodable<__D> for SwitchTargets[src]

impl<'tcx, __E: TyEncoder<'tcx>> Encodable<__E> for SwitchTargets[src]

impl<'__ctx> HashStable<StableHashingContext<'__ctx>> for SwitchTargets[src]

impl PartialEq<SwitchTargets> for SwitchTargets[src]

impl StructuralPartialEq for SwitchTargets[src]

Auto Trait Implementations

impl RefUnwindSafe for SwitchTargets

impl Send for SwitchTargets

impl Sync for SwitchTargets

impl Unpin for SwitchTargets

impl UnwindSafe for SwitchTargets

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized, 
[src]

impl<T> Borrow<T> for T where
    T: ?Sized, 
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized, 
[src]

impl<'a, T> Captures<'a> for T where
    T: ?Sized, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> MaybeResult<T> for T[src]

type Error = !

impl<T> ToOwned for T where
    T: Clone, 
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> WithConstness for T[src]