pub enum TypeVar {
Known(Loc<()>, KnownType, Vec<TypeVarID>),
Unknown(Loc<()>, u64, TraitList, MetaType),
}Expand description
A type variable represents the type of something in the program. It is mapped to expressions by type equations in the TypeState.
When TypeVars are passed externally into TypeState, they must be checked for replacement, as the type inference process might have refined them.
Variants§
Known(Loc<()>, KnownType, Vec<TypeVarID>)
The base type is known and has a list of parameters
Unknown(Loc<()>, u64, TraitList, MetaType)
The type is unknown, but must satisfy the specified traits. When the generic substitution is done, the TypeVars will be carried over to the KnownType type vars
Implementations§
Source§impl TypeVar
impl TypeVar
pub fn into_known(&self, type_state: &TypeState) -> Option<KnownTypeVar>
pub fn insert(self, into: &mut TypeState) -> TypeVarID
pub fn array(loc: Loc<()>, inner: TypeVarID, size: TypeVarID) -> Self
pub fn tuple(loc: Loc<()>, inner: Vec<TypeVarID>) -> Self
pub fn unit(loc: Loc<()>) -> Self
pub fn wire(loc: Loc<()>, inner: TypeVarID) -> Self
pub fn backward( loc: Loc<()>, inner: TypeVarID, type_state: &mut TypeState, ) -> Self
pub fn inverted(loc: Loc<()>, inner: TypeVarID) -> Self
pub fn expect_known<T, U, K, O>(&self, on_known: K, on_unknown: U) -> T
pub fn expect_named<T, E, U, K, O>( &self, on_named: K, on_unknown: U, on_other: O, on_error: E, ) -> T
Sourcepub fn resolve_named_or_inverted(
&self,
inverted_now: bool,
type_state: &TypeState,
) -> ResolvedNamedOrInverted
pub fn resolve_named_or_inverted( &self, inverted_now: bool, type_state: &TypeState, ) -> ResolvedNamedOrInverted
Expect a named type, or TypeVar::Inverted(named), or a recursive inversion. inverted_now is stateful and used to track if we are currently in an inverted context.
pub fn expect_specific_named<T, U, K, O>( &self, name: NameID, on_correct: K, on_unknown: U, on_other: O, ) -> T
Sourcepub fn expect_integer<T, E, U, K, O>(
&self,
on_integer: K,
on_unknown: U,
on_other: O,
on_error: E,
) -> T
pub fn expect_integer<T, E, U, K, O>( &self, on_integer: K, on_unknown: U, on_other: O, on_error: E, ) -> T
Assumes that this type is KnownType::Integer(size) and calls on_integer then. Otherwise calls on_unknown or on_other depending on the type. If the integer is given type params, panics
Sourcepub fn expect_string<T, E, U, K, O>(
&self,
on_string: K,
on_unknown: U,
on_other: O,
on_error: E,
) -> T
pub fn expect_string<T, E, U, K, O>( &self, on_string: K, on_unknown: U, on_other: O, on_error: E, ) -> T
Assumes that this type is KnownType::String(val) and calls on_string then. Otherwise calls on_unknown or on_other depending on the type. If the integer is given type params, panics
pub fn display(&self, type_state: &TypeState) -> String
pub fn display_with_meta( &self, display_meta: bool, type_state: &TypeState, ) -> String
Trait Implementations§
Source§impl<'de> Deserialize<'de> for TypeVar
impl<'de> Deserialize<'de> for TypeVar
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Ord for TypeVar
impl Ord for TypeVar
Source§impl PartialOrd for TypeVar
impl PartialOrd for TypeVar
impl Eq for TypeVar
impl StructuralPartialEq for TypeVar
Auto Trait Implementations§
impl Freeze for TypeVar
impl RefUnwindSafe for TypeVar
impl Send for TypeVar
impl Sync for TypeVar
impl Unpin for TypeVar
impl UnwindSafe for TypeVar
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more