macro_rules! somni_struct {
($ctx:ident, $name:ident { $($field:ident : $value:expr),* $(,)? }) => { ... };
}Expand description
Constructs a SomniStruct value from Rust.
Field values are converted eagerly through the given type context (&mut T,
obtainable via Context::type_context), so string fields are interned and
nested structs may be built with nested invocations.
use somni_expr::{somni_struct, Context, ExprContext, TypedValue};
let mut ctx = Context::new();
let tc = ctx.type_context();
let point = somni_struct!(tc, Point { x: 1u64, y: 2u64 });
assert_eq!(point.name(), "Point");
assert_eq!(point.fields()["x"], TypedValue::Int(1));