| Crates.io | mikro |
| lib.rs | mikro |
| version | 0.1.2 |
| created_at | 2025-08-20 23:41:07.693222+00 |
| updated_at | 2025-08-21 19:23:12.465117+00 |
| description | embeddable mikro interpreter for Rust apps |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1804084 |
| size | 30,684 |
micro is an embedded commands language for rust which supports: variables, if/else, for identifier in range loops and integration with a host state of any type (trough generics).
fn print(args: &[Value], st: &mut State, i: &mut Interner) -> Result<Value, RuntimeError> {
for (idx, v) in args.iter().enumerate() {
if idx > 0 { st.out.push(' '); }
match v {
Value::Int(x) => st.out.push_str(&x.to_string()),
Value::Float(x) => st.out.push_str(&x.to_string()),
Value::Bool(x) => st.out.push_str(&x.to_string()),
Value::Str(sym) => st.out.push_str(i.resolve(*sym)),
Value::Unit => st.out.push_str("unit"),
}
}
st.out.push('\n');
Ok(Value::Unit)
}
static BUILTINS: mikro::Map<&'static str, Builtin<State>> = mikro::phf_map! {
"print" => print as Builtin<State>
};
struct State{}
fn main() {
let code = r#"
a = 0
print(a)
"#;
let mut interpreter = Interpreter::<State>::new(&BUILTINS);
interpreter.run(&mut State{},code);
}