wll_docs/convert/
using_expr.rs1use wolfram_library_link::{
2 export,
3 expr::{Expr, Symbol},
4};
5
6struct Point {
7 x: f64,
8 y: f64,
9}
10
11#[export(wstp)]
12fn create_point2(args: Vec<Expr>) -> Expr {
13 assert!(args.is_empty());
14
15 let point = Point { x: 3.0, y: 4.0 };
16
17 point.to_expr()
18}
19
20impl Point {
21 fn to_expr(&self) -> Expr {
22 let Point { x, y } = *self;
23
24 Expr::normal(Symbol::new("System`Point"), vec![Expr::list(vec![
25 Expr::real(x),
26 Expr::real(y),
27 ])])
28 }
29}