Enum kailua_types::ty::T
[−]
[src]
pub enum T<'a> { Dynamic(Dyn), All, None, Boolean, True, False, Integer, Number, String, Thread, UserData, Int(i32), Str(Cow<'a, Str>), Tables(Cow<'a, Tables>), Functions(Cow<'a, Functions>), Class(Class), TVar(TVar), Union(Cow<'a, Unioned>), }
A value type, except for nil
which is specially treated.
Unions are also special in that they can be generated only from the type specification.
Also, literal types in T
are "implicit" in that they will be converted to supertypes
when being assigned (otherwise it would be very cumbersome to use);
the type specification generates unions for literal types (even when there is only one item),
so explicitly written literal types are retained on assignment.
Variants
Dynamic(Dyn)
Dynamic type.
All
any
(the top type).
None
A bottom type.
This is not equivalent to a diverging type (only allowed in return types)
because in Kailua T
, T!
and T?
can be almost freely mixed.
Consequently, this represents either a silent nil (nil
), a noisy nil (nil?
)
or a type that can be used in any way except for the conversion (nil!
).
Boolean
boolean
.
True
true
generated from an implicit Lua expression.
False
false
generated from an implicit Lua expression.
Integer
integer
.
Number
number
.
String
string
.
Thread
thread
.
UserData
userdata
.
Int(i32)
An integer literal type generated from an implicit Lua expression.
Str(Cow<'a, Str>)
A string literal type generated from an implicit Lua expression.
Tables(Cow<'a, Tables>)
Table types.
Functions(Cow<'a, Functions>)
Function types.
Class(Class)
Nominal types.
TVar(TVar)
A type variable.
Union(Cow<'a, Unioned>)
Union types, or explicit literal types.
Methods
impl<'a> T<'a>
[src]
fn dummy() -> T<'a>
fn table() -> T<'a>
fn function() -> T<'a>
fn func(f: Function) -> T<'a>
fn ints<I: IntoIterator<Item = i32>>(i: I) -> T<'a>
fn strs<I: IntoIterator<Item = Str>>(i: I) -> T<'a>
fn array(v: Slot) -> T<'a>
fn map<X: Into<Ty>>(k: X, v: Slot) -> T<'a>
fn flags(&self) -> Flags
fn to_ref<'b: 'a>(&'b self) -> T<'b>
fn truthy<'b>(&'b self) -> Cow<'b, T<'a>>
fn falsy<'b>(&'b self) -> Cow<'b, T<'a>>
fn is_dynamic(&self) -> bool
fn is_integral(&self) -> bool
fn is_numeric(&self) -> bool
fn is_stringy(&self) -> bool
fn is_tabular(&self) -> bool
fn is_callable(&self) -> bool
fn is_truthy(&self) -> bool
fn is_falsy(&self) -> bool
fn get_dynamic(&self) -> Option<Dyn>
fn get_tables(&self) -> Option<&Tables>
fn get_functions(&self) -> Option<&Functions>
fn get_tvar(&self) -> Option<TVar>
fn as_string(&self) -> Option<&Str>
fn as_integer(&self) -> Option<i32>
fn coerce<'b>(&'b self) -> Cow<'b, T<'a>>
Coerces "implicit" types into "explicit" types.
This is the only possible way in Kailua for implicit coercions to happen, and does the following:
- Removes implicit literal types from
self
, by replacing them withboolean
,integer
orstring
. This does not affect explicit literal types fromTy::from_kind
. (This happens in the shallow way, as implicit types are incrementally constructed.)
This is used when new variable or field has been added without explicit types, or upper & exact bounds for type variables get updated (lower bounds do not).
fn generalize(self, ctx: &mut TypeContext) -> T<'static>
Replaces type and row variables present in given type to their fresh copies.
Primarily used for function calls where all type variable and row variables are made fresh per each call, so that prior calls cannot affect constraints to later calls.
fn into_send(self) -> T<'static>
fn filter_by_flags<'b>(
&'b self,
flags: Flags,
ctx: &mut TypeContext
) -> TypeResult<Cow<'b, T<'a>>>
&'b self,
flags: Flags,
ctx: &mut TypeContext
) -> TypeResult<Cow<'b, T<'a>>>
Trait Implementations
impl<'a> Clone for T<'a>
[src]
fn clone(&self) -> T<'a>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<'a> Dummy for T<'a>
[src]
impl<'a> Union<Unioned> for T<'a>
[src]
type Output = Unioned
A type of the resulting type.
fn union(
&self,
other: &Unioned,
explicit: bool,
ctx: &mut TypeContext
) -> TypeResult<Unioned>
&self,
other: &Unioned,
explicit: bool,
ctx: &mut TypeContext
) -> TypeResult<Unioned>
Calculates a union type of self
and other
, explicitly or implicitly. Read more
impl<'a> Lattice<Unioned> for T<'a>
[src]
fn assert_sub(&self, other: &Unioned, ctx: &mut TypeContext) -> TypeResult<()>
Asserts that self
is a consistent subtype of other
under the type context.
fn assert_eq(&self, other: &Unioned, ctx: &mut TypeContext) -> TypeResult<()>
Asserts that self
is a consistent type equal to other
under the type context.
impl<'a, 'b> Lattice<T<'b>> for T<'a>
[src]
fn assert_sub(&self, other: &T<'b>, ctx: &mut TypeContext) -> TypeResult<()>
Asserts that self
is a consistent subtype of other
under the type context.
fn assert_eq(&self, other: &T<'b>, ctx: &mut TypeContext) -> TypeResult<()>
Asserts that self
is a consistent type equal to other
under the type context.
impl<'a, 'b> BitOr<T<'b>> for T<'a>
[src]
type Output = T<'static>
The resulting type after applying the |
operator
fn bitor(self, rhs: T<'b>) -> T<'static>
The method for the |
operator
impl<'a, 'b> PartialEq<T<'b>> for T<'a>
[src]
fn eq(&self, other: &T<'b>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.
impl<'a> Display for T<'a>
[src]
fn fmt_displayed(&self, f: &mut Formatter, st: &DisplayState) -> Result
fn display<'b, C>(&'b self, ctx: C) -> Displayed<'b, Self, C>
impl<'a> Debug for T<'a>
[src]
impl<'a> Union<Ty> for T<'a>
[src]
type Output = Ty
A type of the resulting type.
fn union(
&self,
other: &Ty,
explicit: bool,
ctx: &mut TypeContext
) -> TypeResult<Ty>
&self,
other: &Ty,
explicit: bool,
ctx: &mut TypeContext
) -> TypeResult<Ty>
Calculates a union type of self
and other
, explicitly or implicitly. Read more
impl<'a> Lattice<Ty> for T<'a>
[src]
fn assert_sub(&self, other: &Ty, ctx: &mut TypeContext) -> TypeResult<()>
Asserts that self
is a consistent subtype of other
under the type context.
fn assert_eq(&self, other: &Ty, ctx: &mut TypeContext) -> TypeResult<()>
Asserts that self
is a consistent type equal to other
under the type context.