Enum cairo_lang_semantic::expr::pattern::Pattern
source · pub enum Pattern {
Literal(PatternLiteral),
Variable(PatternVariable),
Struct(PatternStruct),
Tuple(PatternTuple),
EnumVariant(PatternEnumVariant),
Otherwise(PatternOtherwise),
}
Expand description
Semantic representation of a Pattern. A pattern is a way to “destructure” values. A pattern may introduce new variables that are bound to inner values of a specific value. For example, a tuple pattern destructures a tuple and may result in new variables for an elements of that tuple. This is used both in let statements and match statements.
Variants§
Literal(PatternLiteral)
Variable(PatternVariable)
Struct(PatternStruct)
Tuple(PatternTuple)
EnumVariant(PatternEnumVariant)
Otherwise(PatternOtherwise)
Implementations§
source§impl Pattern
impl Pattern
pub fn ty(&self, _db: &dyn SemanticGroup) -> TypeId
pub fn variables(&self) -> Vec<&PatternVariable>
pub fn stable_ptr(&self) -> PatternPtr
Trait Implementations§
source§impl<'a, T: ?Sized + Upcast<ExprFormatter<'a>>> DebugWithDb<T> for Pattern
impl<'a, T: ?Sized + Upcast<ExprFormatter<'a>>> DebugWithDb<T> for Pattern
source§impl PartialEq for Pattern
impl PartialEq for Pattern
source§impl<T: SemanticRewriter<PatternLiteral, Error> + SemanticRewriter<PatternVariable, Error> + SemanticRewriter<PatternStruct, Error> + SemanticRewriter<PatternTuple, Error> + SemanticRewriter<PatternEnumVariant, Error> + SemanticRewriter<PatternOtherwise, Error>, Error> SemanticObject<T, Error> for Pattern
impl<T: SemanticRewriter<PatternLiteral, Error> + SemanticRewriter<PatternVariable, Error> + SemanticRewriter<PatternStruct, Error> + SemanticRewriter<PatternTuple, Error> + SemanticRewriter<PatternEnumVariant, Error> + SemanticRewriter<PatternOtherwise, Error>, Error> SemanticObject<T, Error> for Pattern
fn default_rewrite(self, rewriter: &mut T) -> Result<Self, Error>
impl Eq for Pattern
impl StructuralEq for Pattern
impl StructuralPartialEq for Pattern
Auto Trait Implementations§
impl RefUnwindSafe for Pattern
impl Send for Pattern
impl Sync for Pattern
impl Unpin for Pattern
impl UnwindSafe for Pattern
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
Mutably borrows from an owned value. Read more
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.