Rearrange the types modules a bunch
This commit is contained in:
parent
82b96abd62
commit
ddfac28b8c
5 changed files with 103 additions and 65 deletions
24
src/types/value.rs
Normal file
24
src/types/value.rs
Normal 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)
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue