pub enum Type {
Int,
Num,
Bool,
Logical,
String,
Tensor {
shape: Option<Vec<Option<usize>>>,
},
Cell {
element_type: Option<Box<Type>>,
length: Option<usize>,
},
Function {
params: Vec<Type>,
returns: Box<Type>,
},
Void,
Unknown,
Union(Vec<Type>),
Struct {
known_fields: Option<Vec<String>>,
},
}Expand description
Enhanced type system used throughout RunMat for HIR and builtin functions Designed to mirror Value variants for better type inference and LSP support
Variants§
Int
Integer number type
Num
Floating-point number type
Bool
Boolean type
Logical
Logical array type (N-D boolean array)
String
String type
Tensor
Tensor type with optional shape information (column-major semantics in runtime)
Fields
Cell
Cell array type with optional element type information
Fields
Function
Function type with parameter and return types
Void
Void type (no value)
Unknown
Unknown type (for type inference)
Union(Vec<Type>)
Union type (multiple possible types)
Struct
Struct-like type with optional known field set (purely for inference)
Implementations§
Source§impl Type
impl Type
Sourcepub fn tensor_with_shape(shape: Vec<usize>) -> Self
pub fn tensor_with_shape(shape: Vec<usize>) -> Self
Create a tensor type with known shape
Sourcepub fn is_compatible_with(&self, other: &Type) -> bool
pub fn is_compatible_with(&self, other: &Type) -> bool
Check if this type is compatible with another type
Sourcepub fn from_value(value: &Value) -> Type
pub fn from_value(value: &Value) -> Type
Infer type from a Value
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Type
impl<'de> Deserialize<'de> for Type
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>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Type
impl StructuralPartialEq for Type
Auto Trait Implementations§
impl Freeze for Type
impl RefUnwindSafe for Type
impl Send for Type
impl Sync for Type
impl Unpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.