pub trait Expression {
// Provided methods
fn as_xpr(&self) -> Xpr<Term<&Self>>
where Self: Sized { ... }
fn into_xpr(self) -> Xpr<Term<Self>>
where Self: Sized { ... }
}
Expand description
A trait for converting an instance into xpr terminals
Provided Methods§
Sourcefn as_xpr(&self) -> Xpr<Term<&Self>>where
Self: Sized,
fn as_xpr(&self) -> Xpr<Term<&Self>>where
Self: Sized,
Wrap a reference of self in an Xpr terminal
Examples found in repository?
examples/vector_expression_ref.rs (line 78)
69pub fn main() {
70 // Create a couple of vectors
71 let x1 = Vec::new([0.6; 5000]);
72 let x2 = Vec::new([1.0; 5000]);
73 let x3 = Vec::new([40.0; 5000]);
74 let x4 = Vec::new([100.0; 5000]);
75 let x5 = Vec::new([3000.0; 5000]);
76
77 // A chained addition without any Vec temporaries!
78 let v = Vec::from(x1.as_xpr() + &x2 + &x3 + &x4 + &x5);
79 println!("v[0..5] = {:?}", &v[0..5]);
80}
Sourcefn into_xpr(self) -> Xpr<Term<Self>>where
Self: Sized,
fn into_xpr(self) -> Xpr<Term<Self>>where
Self: Sized,
Consume self and return as Xpr terminal
Examples found in repository?
examples/vector_expression.rs (line 54)
52pub fn main() {
53 // Create a couple of vectors and convert to Xpr expressions
54 let x1 = Vec::new([0.6; 5000]).into_xpr();
55 let x2 = Vec::new([1.0; 5000]).into_xpr();
56 let x3 = Vec::new([40.0; 5000]).into_xpr();
57 let x4 = Vec::new([100.0; 5000]).into_xpr();
58 let x5 = Vec::new([3000.0; 5000]).into_xpr();
59
60 // A chained addition without any Vec temporaries!
61 let v = Vec::from(x1 + x2 + x3 + x4 + x5);
62 println!("v[0..5] = {:?}", &v.0[0..5]);
63}