Wholesale move modules from src/types to types/src
This commit is contained in:
parent
0e6231bd94
commit
27f1fb63ea
5 changed files with 0 additions and 0 deletions
31
types/src/value.rs
Normal file
31
types/src/value.rs
Normal file
|
@ -0,0 +1,31 @@
|
|||
/* types/value.rs
|
||||
* Eryn Wells <eryn@erynwells.me>
|
||||
*/
|
||||
|
||||
use std::fmt::Debug;
|
||||
use std::any::Any;
|
||||
|
||||
pub trait Value: Debug + ValueEq + IsBool + IsChar {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait IsBool {
|
||||
fn is_bool(&self) -> bool { false }
|
||||
}
|
||||
|
||||
pub trait IsChar {
|
||||
fn is_char(&self) -> bool { false }
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue