Derive Macro oy::InteractiveRoot [−][src]
#[derive(InteractiveRoot)]
Derive this on a struct to make it an interactive access point for your application.
Same as #[derive(Interactive)]
but with two additional impls:
InteractiveRoot
with its default methodsMethods
as a way to access free functions marked with the attributeFunction
(only available with default features on).
use oy::{Interactive, InteractiveRoot, Methods, Function}; #[derive(Interactive)] struct SomethingInteractive; #[Methods] impl SomethingInteractive{ fn ping(&self) -> &str{ "pong" } } #[Function] fn add_one(a: u32) -> u32 { a + 1 } let something = SomethingInteractive; #[derive(InteractiveRoot)] struct Root { field: SomethingInteractive, } let mut root = Root { field: something }; assert_eq!(root.eval_to_string("field.ping()"), "\"pong\""); assert_eq!(root.eval_to_string("add_one(42)"), "43");