Rearrange the types modules a bunch

This commit is contained in:
Eryn Wells 2017-04-03 14:51:39 -04:00
parent 82b96abd62
commit ddfac28b8c
5 changed files with 103 additions and 65 deletions

24
src/types/value.rs Normal file
View file

@ -0,0 +1,24 @@
/* types/value.rs
* Eryn Wells <eryn@erynwells.me>
*/
use std::fmt::Debug;
use std::any::Any;
pub trait Value: Debug + ValueEq {
fn as_value(&self) -> &Value;
}
/// A trait on value types that makes it easier to compare values of disparate types. The methods
/// provided by this trait are used by the PartialEq implementation on Values.
pub trait ValueEq {
fn eq(&self, other: &Value) -> bool;
fn as_any(&self) -> &Any;
}
impl<'lhs,'rhs> PartialEq<Value+'rhs> for Value+'lhs {
fn eq(&self, other: &(Value+'rhs)) -> bool {
ValueEq::eq(self, other)
}
}