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

A type used to indicate an empty Arr.

Null value.

A boolean type.

A signed integer type.

A fractional type.

A character type.

A string type.

An array type, containing the type of its sub-elements.

A tuple type, containing the types of its sub-elements.

An object type.

Methods

impl Type
[src]

[src]

Returns true if this type is strictly the same as other. Usually you want to use eq() instead.

[src]

Returns true if this Type contains Any.

[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]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for Type
[src]

[src]

Formats the value using the given formatter.

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.

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

1.0.0
[src]

This method tests for !=.

impl Eq for Type
[src]

impl Display for Type
[src]

[src]

Formats the value using the given formatter. Read more