pub enum Constraint {
Variant {
ty: TypeId,
variant: VariantId,
fields: TupleIndex,
},
ConstInt {
val: i128,
ty: TypeId,
},
ConstPrim {
val: Sym,
},
Some,
}
Expand description
Pattern matches which can fail. Some binding sites are the result of successfully matching a constraint. A rule applies constraints to binding sites to determine whether the rule matches.
Variants§
Variant
The value must match this enum variant.
Fields
ty: TypeId
Which enum type is being matched? This is implied by the binding where the constraint is applied, but recorded here for convenience.
fields: TupleIndex
Number of fields in this variant of this enum. This is recorded in the constraint for convenience, to avoid needing to look up the variant in a sema::TypeEnv.
ConstInt
The value must equal this integer literal.
Fields
ConstPrim
The value must equal this Rust primitive value.
Some
The value must be an Option::Some
, from a fallible extractor.
Implementations§
source§impl Constraint
impl Constraint
sourcepub fn bindings_for(self, source: BindingId) -> Vec<Binding>
pub fn bindings_for(self, source: BindingId) -> Vec<Binding>
Return the nested Bindings from matching the given Constraint against the given BindingId.
Trait Implementations§
source§impl Clone for Constraint
impl Clone for Constraint
source§fn clone(&self) -> Constraint
fn clone(&self) -> Constraint
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for Constraint
impl Debug for Constraint
source§impl Hash for Constraint
impl Hash for Constraint
source§impl Ord for Constraint
impl Ord for Constraint
source§fn cmp(&self, other: &Constraint) -> Ordering
fn cmp(&self, other: &Constraint) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq for Constraint
impl PartialEq for Constraint
source§impl PartialOrd for Constraint
impl PartialOrd for Constraint
impl Copy for Constraint
impl Eq for Constraint
impl StructuralPartialEq for Constraint
Auto Trait Implementations§
impl Freeze for Constraint
impl RefUnwindSafe for Constraint
impl Send for Constraint
impl Sync for Constraint
impl Unpin for Constraint
impl UnwindSafe for Constraint
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,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)