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
Function
Variable(Rc<RefCell<TypeVariableState>>)
Forall
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
impl Type
pub fn get_function_ret(&self) -> Option<&Type>
pub fn has_name(&self, name: &str) -> bool
pub fn get_qualified_id(&self) -> Option<&str>
pub fn get_underlying(&self) -> Option<&Type>
pub fn is_result(&self) -> bool
pub fn is_option(&self) -> bool
pub fn is_unit(&self) -> bool
pub fn tuple_arity(&self) -> Option<usize>
pub fn is_tuple(&self) -> bool
pub fn is_ref(&self) -> bool
pub fn is_receiver_placeholder(&self) -> bool
pub fn is_unknown(&self) -> bool
pub fn is_receiver(&self) -> bool
pub fn is_ignored(&self) -> bool
pub fn is_variadic(&self) -> Option<Type>
pub fn is_string(&self) -> bool
pub fn is_slice_of(&self, element_name: &str) -> bool
pub fn is_byte_slice(&self) -> bool
pub fn is_rune_slice(&self) -> bool
pub fn is_byte_or_rune_slice(&self) -> bool
pub fn has_byte_or_rune_slice_underlying(&self) -> bool
pub fn is_boolean(&self) -> bool
pub fn is_rune(&self) -> bool
pub fn is_float64(&self) -> bool
pub fn is_float32(&self) -> bool
pub fn is_float(&self) -> bool
pub fn is_variable(&self) -> bool
pub fn is_unbound_variable(&self) -> bool
pub fn is_numeric(&self) -> bool
pub fn is_ordered(&self) -> bool
pub fn is_complex(&self) -> bool
pub fn is_unsigned_int(&self) -> bool
pub fn is_never(&self) -> bool
pub fn is_error(&self) -> bool
pub fn has_unbound_variables(&self) -> bool
pub fn remove_found_type_names(&self, names: &mut HashSet<EcoString>)
Source§impl Type
impl Type
pub fn get_name(&self) -> Option<&str>
pub fn wraps(&self, name: &str, inner: &Type) -> bool
pub fn get_function_params(&self) -> Option<&[Type]>
pub fn param_count(&self) -> usize
pub fn get_param_mutability(&self) -> &[bool]
pub fn with_replaced_first_param(&self, new_first: &Type) -> Type
pub fn get_bounds(&self) -> &[Bound]
pub fn get_qualified_name(&self) -> EcoString
pub fn inner(&self) -> Option<Type>
pub fn ok_type(&self) -> Type
pub fn err_type(&self) -> Type
Source§impl Type
impl Type
pub fn unwrap_forall(&self) -> &Type
pub fn strip_refs(&self) -> Type
pub fn with_receiver_placeholder(self) -> Type
pub fn remove_vars(types: &[&Type]) -> (Vec<Type>, Vec<EcoString>)
pub fn contains_type(&self, target: &Type) -> bool
Sourcepub fn shallow_resolve(&self) -> Type
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).
pub fn resolve(&self) -> Type
Source§impl Type
impl Type
pub fn underlying_numeric_type(&self) -> Option<Type>
pub fn has_underlying_numeric_type(&self) -> bool
pub fn numeric_family(&self) -> Option<NumericFamily>
pub fn is_numeric_compatible_with(&self, other: &Type) -> bool
pub fn is_aliased_numeric_type(&self) -> bool
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more