Files
RustPython/examples/hello_embed.rs
2022-08-23 05:08:24 +09:00

20 lines
492 B
Rust

use rustpython_vm as vm;
fn main() -> vm::PyResult<()> {
vm::Interpreter::without_stdlib(Default::default()).enter(|vm| {
let scope = vm.new_scope_with_builtins();
let code_obj = vm
.compile(
r#"print("Hello World!")"#,
vm::compiler::Mode::Exec,
"<embedded>".to_owned(),
)
.map_err(|err| vm.new_syntax_error(&err))?;
vm.run_code_obj(code_obj, scope)?;
Ok(())
})
}