pub fn to_value(value: impl ToValue) -> Result<Value, RuntimeError>
Expand description
Convert something into the dynamic Value
.
ยงExamples
use rune::{ToValue, Vm};
use std::sync::Arc;
#[derive(ToValue)]
struct Foo {
field: u64,
}
let mut sources = rune::sources! {
entry => {
pub fn main(foo) {
foo.field + 1
}
}
};
let unit = rune::prepare(&mut sources).build()?;
let mut vm = Vm::without_runtime(Arc::new(unit));
let foo = vm.call(["main"], (Foo { field: 42 },))?;
let foo: u64 = rune::from_value(foo)?;
assert_eq!(foo, 43);