[−][src]Struct cranelift_codegen_meta::srcgen::Match
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: String
arms: BTreeMap<(Vec<String>, String), BTreeSet<String>>
catch_all: Option<String>
The clause for the placeholder pattern _.
Methods
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]
&mut self,
name: T,
fields: Vec<S>,
body: T
)
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]
&mut self,
name: impl Into<String>,
body: impl Into<String>
)
Adds an arm that doesn't read anythings from the fields to the Match statement.
Auto Trait Implementations
impl RefUnwindSafe for Match
impl Send for Match
impl Sync for Match
impl Unpin for Match
impl UnwindSafe for Match
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,