[−][src]Enum over::types::Type
Enum of possible types for Value
s.
Variants
Any
A type used to indicate an empty Arr.
Null
Null value.
Bool
A boolean type.
Int
A signed integer type.
Frac
A fractional type.
Char
A character type.
Str
A 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.
Obj
An object type.
Methods
impl Type
[src]
pub 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.
pub fn has_any(&self) -> bool
[src]
Returns true if this Type
contains Any
.
pub 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 PartialEq<Type> 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]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl Eq for Type
[src]
impl Clone for Type
[src]
fn clone(&self) -> Type
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Display for Type
[src]
impl Debug for Type
[src]
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> From for T
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,