pub enum Type {
Show 32 variants
I8,
I16,
I32,
I64,
U8,
U16,
U32,
U64,
F32,
F64,
Decimal,
Char,
Bool,
String,
Object,
Dynamic,
Void,
Null,
Unit(String),
Content(String),
Tag(String),
Own(String, Vec<Type>),
Param(String),
Static(String, Vec<Type>),
Game(String),
Yog(String),
Namespace(String),
Array(Box<Type>, usize),
Tuple(Vec<Type>, Vec<Option<String>>),
Fn(Vec<Type>, Box<Type>),
Nullable(Box<Type>),
Unknown,
}Expand description
A type.
Variants§
I8
I16
I32
I64
U8
U16
U32
U64
F32
F64
Decimal
Char
Bool
String
Object
object: every type converts to it.
Dynamic
dynamic: checked when the code runs, not here.
Void
Null
null before it meets a type.
Unit(String)
A quantity with a unit: Ticks, Seconds, Blocks, a mod’s own.
Content(String)
A content’s id of a kind: an ItemId is Content("item") (content_ids.rs).
Tag(String)
A tag of a content kind: a TagId<ItemId> is Tag("item")
(content_ids.rs); "" of kinds not one.
Own(String, Vec<Type>)
A type the source declares, by name, with its type arguments
(Box<i32>; none when it isn’t generic).
Param(String)
A type parameter (T) where its argument isn’t known: in its
generic’s own code, or a method’s before inference.
Static(String, Vec<Type>)
An own type named where a value goes (Mode in Mode.Idle): its
static members and its cases.
A type named where a value goes (Math in Math.Max), with the
type arguments written (Comparer<i32> in Comparer<i32>.Default).
Game(String)
A game class, by its internal name (.yns only).
Yog(String)
Yog’s: a handle (Player), a domain’s group (Chat), a struct or
an enum an action answers with — by name.
Namespace(String)
A namespace (Game.World), on the way to what’s in it.
Array(Box<Type>, usize)
An array: T[] (rank 1), T[,] (rank 2); a Java array a game
class gives or takes too.
Tuple(Vec<Type>, Vec<Option<String>>)
(i32 X, string): its items’ types, and their names where given
(names don’t make tuple types apart: (i32 X) is (i32 Y)).
Fn(Vec<Type>, Box<Type>)
A delegate: Action<A, B> (its result void), Func<A, R>.
Nullable(Box<Type>)
Unknown
Not known here (the library’s, or what couldn’t be typed): checks involving it pass, so one gap doesn’t cascade.
Implementations§
Source§impl Type
impl Type
pub fn nullable(self) -> Type
pub fn is_nullable(&self) -> bool
pub fn known(&self) -> bool
pub fn is_numeric(&self) -> bool
pub fn is_integer(&self) -> bool
Sourcepub fn converts_to(&self, to: &Type) -> bool
pub fn converts_to(&self, to: &Type) -> bool
Whether a value of self goes where to is wanted without a cast.
Sourcepub fn integer_width(&self) -> Option<(u32, bool)>
pub fn integer_width(&self) -> Option<(u32, bool)>
The type both of two numbers become in an operation (i32 + f64 is f64).
A whole number’s width in bits and whether it’s signed (u8: 8, no).