children count

This commit is contained in:
Rendo 2025-11-08 20:50:22 +05:00
commit c3b04be872

View file

@ -8,6 +8,7 @@ mod node_modifier;
pub struct Node { pub struct Node {
children: Vec<Node>, children: Vec<Node>,
handler: NodeHandler, handler: NodeHandler,
max_children_count: Option<usize>,
} }
impl Node { impl Node {
@ -35,18 +36,21 @@ impl Node {
Node { Node {
children: vec![], children: vec![],
handler: NodeHandler::Number { number: n }, handler: NodeHandler::Number { number: n },
max_children_count: None,
} }
} }
pub fn function(func: fn(Vec<f64>) -> f64) -> Node { pub fn function(func: fn(Vec<f64>) -> f64) -> Node {
Node { Node {
children: vec![], children: vec![],
handler: NodeHandler::Function { function: func }, handler: NodeHandler::Function { function: func },
max_children_count: Some(1),
} }
} }
pub fn variable(getter: fn() -> f64) -> Node { pub fn variable(getter: fn() -> f64) -> Node {
Node { Node {
children: vec![], children: vec![],
handler: NodeHandler::Variable { getter }, handler: NodeHandler::Variable { getter },
max_children_count: Some(0),
} }
} }
} }