Enum over::types::Type
[−]
[src]
pub enum Type {
Any,
Null,
Bool,
Int,
Frac,
Char,
Str,
Arr(Box<Type>),
Tup(Vec<Type>),
Obj,
}Enum of possible types for Values.
Variants
AnyA type used to indicate an empty Arr.
NullNull value.
BoolA boolean type.
IntA signed integer type.
FracA fractional type.
CharA character type.
StrA string type.
Arr(Box<Type>)An array type, containing the type of its sub-elements.
Tup(Vec<Type>)A tuple type, containing the types of its sub-elements.
ObjAn object type.
Methods
impl Type[src]
fn is(&self, other: &Type) -> bool[src]
Returns true if this type is strictly the same as other.
Usually you want to use eq() instead.
fn has_any(&self) -> bool[src]
Returns true if this Type contains Any.
fn most_specific(type1: &Type, type2: &Type) -> Option<(Type, bool)>[src]
Returns a type with the most specificity that can be applied to the two input types as well
as true if the returned type is not maximally specific, that is, it contains Any. If no
single type can be applied to both input types (e.g. the types are Str and Int), returns
None.
Examples
use over::types::Type; use over::types::Type::*; use over::value::Value; let val1: Value = tup!(arr![], arr![2]).into(); let val2: Value = tup!(arr!['c'], arr![]).into(); let (specific_type, has_any) = Type::most_specific(&val1.get_type(), &val2.get_type()).unwrap(); assert_eq!(specific_type, Tup(vec![Arr(Box::new(Char)), Arr(Box::new(Int))])); assert!(!has_any);
Trait Implementations
impl Clone for Type[src]
fn clone(&self) -> Type[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
Performs copy-assignment from source. Read more
impl Debug for Type[src]
impl PartialEq for Type[src]
Two types are considered equal if one of them is Any or they have the same variant.
In the case of Arr and Tup, the inner types are recursively checked for equality.
fn eq(&self, other: &Self) -> bool[src]
This method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
This method tests for !=.