Simplify bool.rs a bunch
This commit is contained in:
parent
beb32bf2ce
commit
61f8cfccb5
1 changed files with 9 additions and 22 deletions
|
@ -1,30 +1,17 @@
|
||||||
/* types/bool.rs
|
/* types/src/bool.rs
|
||||||
* Eryn Wells <eryn@erynwells.me>
|
* Eryn Wells <eryn@erynwells.me>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use std::any::Any;
|
use object::Object;
|
||||||
use value::*;
|
use predicates::IsBool;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
impl IsBool for Object {
|
||||||
pub struct Bool(pub bool);
|
fn is_bool(&self) -> bool {
|
||||||
|
match *self {
|
||||||
impl Value for Bool {
|
Object::Bool(_) => true,
|
||||||
fn as_value(&self) -> &Value { self }
|
_ => false,
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_any(&self) -> &Any { self }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue