pub struct CodePattern {
pub node: NodeKind,
pub arm_count: Option<usize>,
pub arms: Option<Vec<ArmPattern>>,
pub children: HashMap<String, PatternExpr>,
pub capture: Option<String>,
pub ellipsis: bool,
}Expand description
AST Pattern for structural matching
Fields§
§node: NodeKindAST node type to match
arm_count: Option<usize>Required arm count (for Match nodes)
arms: Option<Vec<ArmPattern>>Arm patterns (for Match nodes, order-independent matching)
children: HashMap<String, PatternExpr>Child patterns (field name -> pattern)
capture: Option<String>Capture variable (e.g., “$RECEIVER”)
ellipsis: boolMatch zero or more items (ellipsis)
Implementations§
Source§impl CodePattern
impl CodePattern
Sourcepub fn with_child(self, name: impl Into<String>, pattern: PatternExpr) -> Self
pub fn with_child(self, name: impl Into<String>, pattern: PatternExpr) -> Self
Add a child pattern
Sourcepub fn with_capture(self, var: impl Into<String>) -> Self
pub fn with_capture(self, var: impl Into<String>) -> Self
Set capture variable
Sourcepub fn with_ellipsis(self) -> Self
pub fn with_ellipsis(self) -> Self
Set ellipsis mode
Trait Implementations§
Source§impl Clone for CodePattern
impl Clone for CodePattern
Source§fn clone(&self) -> CodePattern
fn clone(&self) -> CodePattern
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CodePattern
impl Debug for CodePattern
Source§impl<'de> Deserialize<'de> for CodePattern
impl<'de> Deserialize<'de> for CodePattern
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl JsonSchema for CodePattern
impl JsonSchema for CodePattern
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreSource§impl PartialEq for CodePattern
impl PartialEq for CodePattern
Source§fn eq(&self, other: &CodePattern) -> bool
fn eq(&self, other: &CodePattern) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for CodePattern
impl Serialize for CodePattern
impl StructuralPartialEq for CodePattern
Auto Trait Implementations§
impl Freeze for CodePattern
impl RefUnwindSafe for CodePattern
impl Send for CodePattern
impl Sync for CodePattern
impl Unpin for CodePattern
impl UnsafeUnpin for CodePattern
impl UnwindSafe for CodePattern
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