pub trait ToDict {
// Required method
fn into_dict(self) -> Dict;
}Expand description
Converts a Rust struct into a Typst Dict.
Derive it with #[derive(ToDict)] (see the
ToDict macro), which also implements ToValue by
wrapping the dict, so derived types can nest.
use typst_template::{ToDict, ToValue, Value};
#[derive(ToDict)]
struct Point {
x: i64,
y: i64,
}
let dict = Point { x: 1, y: 2 }.into_dict();
assert_eq!(dict.get("x").unwrap(), &Value::Int(1));Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".