[][src]Enum over::types::Type

pub enum Type {
    Any,
    Null,
    Bool,
    Int,
    Frac,
    Char,
    Str,
    Arr(Box<Type>),
    Tup(Vec<Type>),
    Obj,
}

Enum of possible types for Values.

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.

#[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_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

impl Send for Type

impl Sync for Type

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.