replaced defaults with new
This commit is contained in:
17
src/calc.rs
17
src/calc.rs
@@ -3,15 +3,6 @@ struct calcNode {
|
|||||||
left: Option<Box<calcNode>>,
|
left: Option<Box<calcNode>>,
|
||||||
right: Option<Box<calcNode>>,
|
right: Option<Box<calcNode>>,
|
||||||
}
|
}
|
||||||
impl Default for calcNode {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self {
|
|
||||||
item: Item::Num(1),
|
|
||||||
left: None,
|
|
||||||
right: None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl calcNode {
|
impl calcNode {
|
||||||
pub fn new(item: Item, left: Option<Box<calcNode>>, right: Option<Box<calcNode>>) -> Self {
|
pub fn new(item: Item, left: Option<Box<calcNode>>, right: Option<Box<calcNode>>) -> Self {
|
||||||
@@ -28,9 +19,13 @@ pub enum Operation {
|
|||||||
Div,
|
Div,
|
||||||
Mult,
|
Mult,
|
||||||
}
|
}
|
||||||
#[derive(Default)]
|
|
||||||
pub struct calcTree {
|
pub struct calcTree {
|
||||||
root: calcNode,
|
root: calcNode,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl calcTree {}
|
impl calcTree {
|
||||||
|
pub fn new(item: Item) -> Self {
|
||||||
|
let root = calcNode::new(item, None, None);
|
||||||
|
Self { root }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user