mirascript-vm 0.1.87

Native Rust virtual machine for MiraScript
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use super::*;

pub(crate) fn assert_initialized(value: &MiraAny) -> Result<()> {
    if matches!(value, MiraAny::Uninitialized) {
        Err(MiraError::runtime("Uninitialized value"))
    } else {
        Ok(())
    }
}

pub(crate) fn assert_non_nil(value: &MiraAny) -> Result<()> {
    assert_initialized(value)?;
    if matches!(value, MiraAny::Nil) {
        Err(MiraError::runtime("Expected non-nil value"))
    } else {
        Ok(())
    }
}