Replace manual type_id
with builtin function of trait Any
Relates to #44
This commit is contained in:
parent
d576cec9b9
commit
2e929ae0fe
@ -95,7 +95,7 @@ impl Operator {
|
|||||||
// Make this a const fn once #57563 is resolved
|
// Make this a const fn once #57563 is resolved
|
||||||
fn is_flatten_chains(&self) -> bool {
|
fn is_flatten_chains(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Operator::Chain => true,
|
Operator::Tuple => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -112,7 +112,8 @@ impl Operator {
|
|||||||
use crate::operator::Operator::*;
|
use crate::operator::Operator::*;
|
||||||
match self {
|
match self {
|
||||||
Add | Sub | Mul | Div | Mod | Exp | Eq | Neq | Gt | Lt | Geq | Leq | And | Or
|
Add | Sub | Mul | Div | Mod | Exp | Eq | Neq | Gt | Lt | Geq | Leq | And | Or
|
||||||
| Tuple | Assign | Chain => Some(2),
|
| Assign | Chain => Some(2),
|
||||||
|
Tuple => None,
|
||||||
Not | Neg | RootNode => Some(1),
|
Not | Neg | RootNode => Some(1),
|
||||||
Const { value: _ } => Some(0),
|
Const { value: _ } => Some(0),
|
||||||
VariableIdentifier { identifier: _ } => Some(0),
|
VariableIdentifier { identifier: _ } => Some(0),
|
||||||
|
@ -11,6 +11,8 @@ use crate::{
|
|||||||
operator::*,
|
operator::*,
|
||||||
value::Value,
|
value::Value,
|
||||||
};
|
};
|
||||||
|
use std::error::Error;
|
||||||
|
use std::any::Any;
|
||||||
|
|
||||||
mod display;
|
mod display;
|
||||||
mod iter;
|
mod iter;
|
||||||
@ -383,7 +385,7 @@ impl Node {
|
|||||||
.last_mut()
|
.last_mut()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.insert_back_prioritized(node, false)
|
.insert_back_prioritized(node, false)
|
||||||
} else if self.children.last().unwrap().operator().id() == node.operator().id() && node.operator().is_flatten_chains() && !self.children.last().unwrap().has_enough_children() {
|
} else if self.children.last().unwrap().operator().type_id() == node.operator().type_id() && node.operator().is_flatten_chains() && !self.children.last().unwrap().has_enough_children() {
|
||||||
// The operators will be chained together, and the next value will be added to this nodes last child.
|
// The operators will be chained together, and the next value will be added to this nodes last child.
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user