binder: snapshot

This commit is contained in:
nym21
2025-12-20 18:19:48 +01:00
parent 25860636f0
commit 8f19bf7350
2 changed files with 12 additions and 2 deletions
+4 -2
View File
@@ -576,18 +576,20 @@ fn generate_tree_initializer(
match child_node {
TreeNode::Leaf(leaf) => {
// Use leaf.name() (vec.name()) for API path, not tree path
let metric_path = format!("/{}", leaf.name());
if let Some(accessor) = metadata.find_index_set_pattern(leaf.indexes()) {
writeln!(
output,
"{}{}: create{}(this, '{}'){}",
indent_str, field_name, accessor.name, child_path, comma
indent_str, field_name, accessor.name, metric_path, comma
)
.unwrap();
} else {
writeln!(
output,
"{}{}: new MetricNode(this, '{}'){}",
indent_str, field_name, child_path, comma
indent_str, field_name, metric_path, comma
)
.unwrap();
}
+8
View File
@@ -35,6 +35,14 @@ pub struct StructuralPattern {
pub fields: Vec<PatternField>,
}
impl StructuralPattern {
/// Returns true if this pattern contains any leaf fields (fields with indexes).
/// Patterns with leaves can't use factory functions because leaf.name() is instance-specific.
pub fn contains_leaves(&self) -> bool {
self.fields.iter().any(|f| !f.indexes.is_empty())
}
}
/// A field in a structural pattern
#[derive(Debug, Clone, PartialOrd, Ord)]
pub struct PatternField {