Enum dyon::Type

source ·
pub enum Type {
Show 18 variants Unreachable, Void, Any, Bool, F64, Vec4, Mat4, Str, Link, Array(Box<Type>), Object, Option(Box<Type>), Result(Box<Type>), Secret(Box<Type>), Thread(Box<Type>), In(Box<Type>), AdHoc(Arc<String>, Box<Type>), Closure(Box<Dfn>),
}
Expand description

Stores a Dyon type.

Variants§

§

Unreachable

Whether a statement is never reached.

§

Void

A no-type.

§

Any

Any type.

§

Bool

Boolean type.

§

F64

F64 type.

§

Vec4

4D vector type.

§

Mat4

4D matrix type.

§

Str

String/text type.

Link type.

§

Array(Box<Type>)

Array type.

§

Object

Object type.

§

Option(Box<Type>)

Option type.

§

Result(Box<Type>)

Result type.

§

Secret(Box<Type>)

Secret type.

§

Thread(Box<Type>)

Thread handle type.

§

In(Box<Type>)

In-type.

§

AdHoc(Arc<String>, Box<Type>)

Ad-hoc type.

§

Closure(Box<Dfn>)

Closure type.

Implementations§

source§

impl Type

source

pub fn all_ext( args: Vec<Type>, ret: Type ) -> (Vec<Arc<String>>, Vec<Type>, Type)

Returns an extension quantified over ad-hoc types.

For example, (vec4, vec4) -> vec4 becomes all T { (T vec4, T vec4) -> T vec4 }.

source

pub fn description(&self) -> String

Returns description of the type.

source

pub fn array() -> Type

Returns an array type with an any as inner type.

source

pub fn object() -> Type

Returns an object type.

source

pub fn option() -> Type

Returns an Option type with an any as inner type.

source

pub fn result() -> Type

Returns a Result type with an any as inner type.

source

pub fn thread() -> Type

Returns a thread handle type with an any as inner type.

source

pub fn in_ty() -> Type

Returns an in-type with an any as inner type.

source

pub fn bind_ty_vars( &self, refine: &Type, names: &[Arc<String>], ty_vars: &mut Vec<Option<Arc<String>>> ) -> Result<Type, String>

Binds refinement type variables.

Returns the type argument to compare to.

source

pub fn insert_var(&mut self, name: &Arc<String>, val: &Arc<String>)

Inserts variable name, replacing ad-hoc type name.

source

pub fn insert_none_var(&mut self, name: &Arc<String>)

Inserts a none ad-hoc variable.

source

pub fn ambiguous(&self, refine: &Type) -> bool

Returns true if a type to be refined is ambiguous relative to this type (directional check).

For example, the type ad-hoc type Foo str is ambiguous with type str. If more was known about the str type with further refinement, then it might turn out to be Bar str, which triggers a collision.

source

pub fn closure_ret_ty(&self) -> Option<Type>

Returns true if the type can be a closure, false otherwise.

source

pub fn goes_with(&self, other: &Type) -> bool

Returns true if a type goes with another type (directional check).

  • bool (argument) goes with sec[bool] (value)
  • f64 (argument) goes with sec[f64] (value)

The opposite is not true, since sec contains extra information.

source

pub fn add_assign(&self, other: &Type) -> bool

Infers type from the += operator.

source

pub fn from_meta_data( node: &str, convert: Convert<'_>, ignored: &mut Vec<Range> ) -> Result<(Range, Type), ()>

Converts meta data into a type.

Trait Implementations§

source§

impl Clone for Type

source§

fn clone(&self) -> Type

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Type

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq<Type> for Type

source§

fn eq(&self, other: &Type) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for Type

Auto Trait Implementations§

§

impl !RefUnwindSafe for Type

§

impl Send for Type

§

impl Sync for Type

§

impl Unpin for Type

§

impl !UnwindSafe for Type

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Err>