pub enum VariableType {
Void,
Bool,
Str,
Int,
Char,
Any,
Unknown,
Func {
params: Vec<VariableType>,
return_type: Box<VariableType>,
source: Option<Module<()>>,
},
ArraySlice(Box<VariableType>),
TupleArray {
item_type: Box<VariableType>,
size: usize,
},
}
Variants§
Implementations§
Source§impl VariableType
impl VariableType
pub fn size(&self) -> usize
pub fn set_source(self, source: Module<()>) -> Self
pub fn get_source(&self) -> Option<Module<()>>
Sourcepub fn convert_to(
&self,
to_convert_to: &Self,
) -> Result<Self, VariableConversionError>
pub fn convert_to( &self, to_convert_to: &Self, ) -> Result<Self, VariableConversionError>
Try to convert this variable type to another. If the conversion is successful, it returns the new variable type. If it is not successful, it returns Err(VariableConversionError).
Note the rules:
- unknown
can be converted to anything
- nothing can be converted to unknown
(except unknown
itself)
- everything can be converted to any
- any
can not be converted to anything else
- every basic type can be converted to itself
Trait Implementations§
Source§impl Clone for VariableType
impl Clone for VariableType
Source§fn clone(&self) -> VariableType
fn clone(&self) -> VariableType
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for VariableType
impl Debug for VariableType
Source§impl Default for VariableType
impl Default for VariableType
Source§fn default() -> VariableType
fn default() -> VariableType
Returns the “default value” for a type. Read more
Source§impl Display for VariableType
impl Display for VariableType
Source§impl FromStr for VariableType
impl FromStr for VariableType
Source§impl PartialEq for VariableType
impl PartialEq for VariableType
impl Eq for VariableType
impl StructuralPartialEq for VariableType
Auto Trait Implementations§
impl Freeze for VariableType
impl !RefUnwindSafe for VariableType
impl !Send for VariableType
impl !Sync for VariableType
impl Unpin for VariableType
impl !UnwindSafe for VariableType
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