mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-06-11 15:33:33 -07:00
binder: snapshot
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user