[][src]Struct cranelift_codegen_meta::srcgen::Match

pub(crate) struct Match {
    expr: String,
    arms: BTreeMap<(Vec<String>, String), BTreeSet<String>>,
    catch_all: Option<String>,
}

Match formatting class.

Match objects collect all the information needed to emit a Rust match expression, automatically deduplicating overlapping identical arms.

Note that this class is ignorant of Rust types, and considers two fields with the same name to be equivalent. BTreeMap/BTreeSet are used to represent the arms in order to make the order deterministic.

Fields

expr: Stringarms: BTreeMap<(Vec<String>, String), BTreeSet<String>>catch_all: Option<String>

The clause for the placeholder pattern _.

Implementations

impl Match[src]

pub fn new(expr: impl Into<String>) -> Self[src]

Create a new match statement on expr.

fn set_catch_all(&mut self, clause: String)[src]

pub fn arm<T: Into<String>, S: Into<String>>(
    &mut self,
    name: T,
    fields: Vec<S>,
    body: T
)
[src]

Add an arm that reads fields to the Match statement.

pub fn arm_no_fields(
    &mut self,
    name: impl Into<String>,
    body: impl Into<String>
)
[src]

Adds an arm that doesn't read anythings from the fields to the Match statement.

Auto Trait Implementations

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<T> From<T> for T[src]

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

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.