Simplify bool.rs a bunch

This commit is contained in:
Eryn Wells 2017-04-22 09:30:28 -07:00
parent beb32bf2ce
commit 61f8cfccb5

View file

@ -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)]