pub struct Viz { /* private fields */ }
Implementations§
Source§impl Viz
impl Viz
Sourcepub fn label(self, info_header: String, info_txt: String) -> Self
pub fn label(self, info_header: String, info_txt: String) -> Self
Examples found in repository?
examples/expr.rs (line 214)
206fn main() {
207 {
208 use expr1::*;
209 let expr = multiply(subtract(literal(1), literal(2)), literal(3));
210
211 let (evaluated, viz) = eval(&expr);
212 assert_eq!(evaluated, -3);
213
214 viz.label("Evaluate Expr".to_string(), "(1 - 2) * 3".to_string())
215 .write("eval.html".to_string());
216
217 let (built_expr, viz) = build_expr(2);
218 let expected = add(add(literal(1), literal(1)), add(literal(1), literal(1)));
219
220 assert_eq!(built_expr, expected);
221
222 viz.label("Build Expr".to_string(), "1 + 1 + 1 + 1".to_string())
223 .write("build_expr.html".to_string());
224 }
225
226 {
227 use expr2::*;
228
229 let valid_expr = divide(subtract(literal(1), literal(7)), literal(3));
230 let invalid_expr = divide(multiply(literal(2), literal(3)), literal(0));
231
232 let (valid_res, valid_viz) = try_eval(&valid_expr);
233 let (invalid_res, invalid_viz) = try_eval(&invalid_expr);
234
235 assert_eq!(valid_res, Ok(-2));
236 assert_eq!(invalid_res, Err("cannot divide by zero"));
237
238 valid_viz
239 .label("Try Eval Valid Expr".to_string(), "(1 - 7) / 3".to_string())
240 .write("try_eval_valid.html".to_string());
241 invalid_viz
242 .label("Try Eval Expr".to_string(), "(2 * 3) / 0".to_string())
243 .write("try_eval_invalid.html".to_string());
244 }
245}
pub fn fuse(self, next: Self, info_header: String, info_txt: String) -> Self
Sourcepub fn write(self, path: String)
pub fn write(self, path: String)
Examples found in repository?
examples/expr.rs (line 215)
206fn main() {
207 {
208 use expr1::*;
209 let expr = multiply(subtract(literal(1), literal(2)), literal(3));
210
211 let (evaluated, viz) = eval(&expr);
212 assert_eq!(evaluated, -3);
213
214 viz.label("Evaluate Expr".to_string(), "(1 - 2) * 3".to_string())
215 .write("eval.html".to_string());
216
217 let (built_expr, viz) = build_expr(2);
218 let expected = add(add(literal(1), literal(1)), add(literal(1), literal(1)));
219
220 assert_eq!(built_expr, expected);
221
222 viz.label("Build Expr".to_string(), "1 + 1 + 1 + 1".to_string())
223 .write("build_expr.html".to_string());
224 }
225
226 {
227 use expr2::*;
228
229 let valid_expr = divide(subtract(literal(1), literal(7)), literal(3));
230 let invalid_expr = divide(multiply(literal(2), literal(3)), literal(0));
231
232 let (valid_res, valid_viz) = try_eval(&valid_expr);
233 let (invalid_res, invalid_viz) = try_eval(&invalid_expr);
234
235 assert_eq!(valid_res, Ok(-2));
236 assert_eq!(invalid_res, Err("cannot divide by zero"));
237
238 valid_viz
239 .label("Try Eval Valid Expr".to_string(), "(1 - 7) / 3".to_string())
240 .write("try_eval_valid.html".to_string());
241 invalid_viz
242 .label("Try Eval Expr".to_string(), "(2 * 3) / 0".to_string())
243 .write("try_eval_invalid.html".to_string());
244 }
245}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Viz
impl RefUnwindSafe for Viz
impl Send for Viz
impl Sync for Viz
impl Unpin for Viz
impl UnwindSafe for Viz
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more