Skip to main content

Type

Enum Type 

Source
pub enum Type {
    Constructor {
        id: EcoString,
        params: Vec<Type>,
        underlying_ty: Option<Box<Type>>,
    },
    Function {
        params: Vec<Type>,
        param_mutability: Vec<bool>,
        bounds: Vec<Bound>,
        return_type: Box<Type>,
    },
    Variable(Rc<RefCell<TypeVariableState>>),
    Forall {
        vars: Vec<EcoString>,
        body: Box<Type>,
    },
    Parameter(EcoString),
    Never,
    Tuple(Vec<Type>),
    Error,
}

Variants§

§

Constructor

Fields

§params: Vec<Type>
§underlying_ty: Option<Box<Type>>
§

Function

Fields

§params: Vec<Type>
§param_mutability: Vec<bool>
§bounds: Vec<Bound>
§return_type: Box<Type>
§

Variable(Rc<RefCell<TypeVariableState>>)

§

Forall

Fields

§body: Box<Type>
§

Parameter(EcoString)

§

Never

§

Tuple(Vec<Type>)

§

Error

Poison type returned after an error has been reported. Unifies with everything silently, preventing cascading diagnostics.

Implementations§

Source§

impl Type

Source

pub fn stringify(&self) -> String

Source§

impl Type

Source

pub fn int() -> Type

Source

pub fn string() -> Type

Source

pub fn bool() -> Type

Source

pub fn unit() -> Type

Source

pub fn float64() -> Type

Source

pub fn rune() -> Type

Source§

impl Type

Source

pub fn nominal(name: &str) -> Self

Source

pub fn uninferred() -> Self

Source

pub fn ignored() -> Self

Source

pub fn get_type_params(&self) -> Option<&[Type]>

Source§

impl Type

Source

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

Source

pub fn has_name(&self, name: &str) -> bool

Source

pub fn get_qualified_id(&self) -> Option<&str>

Source

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

Source

pub fn is_result(&self) -> bool

Source

pub fn is_option(&self) -> bool

Source

pub fn is_unit(&self) -> bool

Source

pub fn tuple_arity(&self) -> Option<usize>

Source

pub fn is_tuple(&self) -> bool

Source

pub fn is_ref(&self) -> bool

Source

pub fn is_receiver_placeholder(&self) -> bool

Source

pub fn is_unknown(&self) -> bool

Source

pub fn is_receiver(&self) -> bool

Source

pub fn is_ignored(&self) -> bool

Source

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

Source

pub fn is_string(&self) -> bool

Source

pub fn is_slice_of(&self, element_name: &str) -> bool

Source

pub fn is_byte_slice(&self) -> bool

Source

pub fn is_rune_slice(&self) -> bool

Source

pub fn is_byte_or_rune_slice(&self) -> bool

Source

pub fn has_byte_or_rune_slice_underlying(&self) -> bool

Source

pub fn is_boolean(&self) -> bool

Source

pub fn is_rune(&self) -> bool

Source

pub fn is_float64(&self) -> bool

Source

pub fn is_float32(&self) -> bool

Source

pub fn is_float(&self) -> bool

Source

pub fn is_variable(&self) -> bool

Source

pub fn is_unbound_variable(&self) -> bool

Source

pub fn is_numeric(&self) -> bool

Source

pub fn is_ordered(&self) -> bool

Source

pub fn is_complex(&self) -> bool

Source

pub fn is_unsigned_int(&self) -> bool

Source

pub fn is_never(&self) -> bool

Source

pub fn is_error(&self) -> bool

Source

pub fn has_unbound_variables(&self) -> bool

Source

pub fn remove_found_type_names(&self, names: &mut HashSet<EcoString>)

Source§

impl Type

Source

pub fn get_name(&self) -> Option<&str>

Source

pub fn wraps(&self, name: &str, inner: &Type) -> bool

Source

pub fn get_function_params(&self) -> Option<&[Type]>

Source

pub fn param_count(&self) -> usize

Source

pub fn get_param_mutability(&self) -> &[bool]

Source

pub fn with_replaced_first_param(&self, new_first: &Type) -> Type

Source

pub fn get_bounds(&self) -> &[Bound]

Source

pub fn get_qualified_name(&self) -> EcoString

Source

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

Source

pub fn ok_type(&self) -> Type

Source

pub fn err_type(&self) -> Type

Source§

impl Type

Source

pub fn unwrap_forall(&self) -> &Type

Source

pub fn strip_refs(&self) -> Type

Source

pub fn with_receiver_placeholder(self) -> Type

Source

pub fn remove_vars(types: &[&Type]) -> (Vec<Type>, Vec<EcoString>)

Source

pub fn contains_type(&self, target: &Type) -> bool

Source

pub fn shallow_resolve(&self) -> Type

Follow Variable::Link chains to the outermost non-variable type. Does NOT recurse into Constructor params, Function params, etc. Use this when you only need the outermost type (e.g. is_never, is_unknown, has_name).

Source

pub fn resolve(&self) -> Type

Source§

impl Type

Trait Implementations§

Source§

impl Clone for Type

Source§

fn clone(&self) -> Type

Returns a duplicate 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 Display for Type

Source§

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

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

impl PartialEq for Type

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

§

impl Freeze for Type

§

impl !RefUnwindSafe for Type

§

impl !Send for Type

§

impl !Sync for Type

§

impl Unpin for Type

§

impl UnsafeUnpin for Type

§

impl !UnwindSafe for Type

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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 T
where T: Clone,

Source§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.