Break type checks into separate traits
This commit is contained in:
parent
b094310b3c
commit
370083e2f0
3 changed files with 30 additions and 2 deletions
|
@ -3,17 +3,22 @@
|
|||
*/
|
||||
|
||||
use std::any::Any;
|
||||
use super::value::*;
|
||||
use value::*;
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub struct Bool(pub bool);
|
||||
|
||||
impl Value for Bool {
|
||||
fn as_value(&self) -> &Value { self }
|
||||
}
|
||||
|
||||
impl IsBool for Bool {
|
||||
fn is_bool(&self) -> bool { true }
|
||||
}
|
||||
|
||||
impl IsChar for Bool { }
|
||||
impl IsNumber for Bool { }
|
||||
|
||||
impl ValueEq for Bool {
|
||||
fn eq(&self, other: &Value) -> bool {
|
||||
other.as_any().downcast_ref::<Self>().map_or(false, |x| x == self)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue