pub enum DestructurePattern {
Identifier(String, Span),
Array(Vec<DestructurePattern>),
Object(Vec<ObjectPatternField>),
Rest(Box<DestructurePattern>),
Decomposition(Vec<DecompositionBinding>),
}Expand description
Pattern for destructuring assignments
Variants§
Identifier(String, Span)
Simple identifier pattern: let x = …
Array(Vec<DestructurePattern>)
Array destructuring: let [a, b, c] = …
Object(Vec<ObjectPatternField>)
Object destructuring: let {x, y} = …
Rest(Box<DestructurePattern>)
Rest pattern: let [a, …rest] = … or let {x, …rest} = …
Decomposition(Vec<DecompositionBinding>)
Decomposition pattern: let a: A, b: B = intersection_value Extracts component types from an intersection type (A + B). Each binding specifies a name and type annotation for the component.
Implementations§
Source§impl DestructurePattern
impl DestructurePattern
Sourcepub fn as_identifier(&self) -> Option<&str>
pub fn as_identifier(&self) -> Option<&str>
Get the identifier name if this is a simple identifier pattern
Sourcepub fn as_identifier_span(&self) -> Option<Span>
pub fn as_identifier_span(&self) -> Option<Span>
Get the identifier span if this is a simple identifier pattern
Sourcepub fn get_identifiers(&self) -> Vec<String>
pub fn get_identifiers(&self) -> Vec<String>
Get all identifier names in this pattern
Sourcepub fn get_bindings(&self) -> Vec<(String, Span)>
pub fn get_bindings(&self) -> Vec<(String, Span)>
Get all identifier names and their source spans in this pattern.
This is the canonical way to extract bound variables from any pattern shape. Both the compiler and LSP should use this method to avoid divergence in how pattern bindings are discovered.
Trait Implementations§
Source§impl Clone for DestructurePattern
impl Clone for DestructurePattern
Source§fn clone(&self) -> DestructurePattern
fn clone(&self) -> DestructurePattern
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more