pub struct Compiler<Ctx> { /* private fields */ }Implementations§
Source§impl<Ctx: EvalType> Compiler<Ctx>
impl<Ctx: EvalType> Compiler<Ctx>
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Examples found in repository?
examples/simple.rs (line 26)
25fn main() {
26 let compiler = Compiler::new().unwrap();
27
28 let greet_user = compiler.compile::<String>("user.greet()").unwrap();
29 let double_age = compiler.compile::<i64>("user.age * 2").unwrap();
30
31 let context = Context {
32 user: User {
33 name: "Bob".into(),
34 age: 45,
35 },
36 };
37
38 assert_eq!(greet_user(&context), "Hello, Bob");
39 assert_eq!(double_age(&context), 90);
40}Sourcepub fn compile<Ret: EvalType>(&self, input: &str) -> Result<BoxedFn<Ctx, Ret>>
pub fn compile<Ret: EvalType>(&self, input: &str) -> Result<BoxedFn<Ctx, Ret>>
Examples found in repository?
examples/simple.rs (line 28)
25fn main() {
26 let compiler = Compiler::new().unwrap();
27
28 let greet_user = compiler.compile::<String>("user.greet()").unwrap();
29 let double_age = compiler.compile::<i64>("user.age * 2").unwrap();
30
31 let context = Context {
32 user: User {
33 name: "Bob".into(),
34 age: 45,
35 },
36 };
37
38 assert_eq!(greet_user(&context), "Hello, Bob");
39 assert_eq!(double_age(&context), 90);
40}pub fn compile_dyn(&self, input: &str) -> Result<DynFn>
Auto Trait Implementations§
impl<Ctx> Freeze for Compiler<Ctx>
impl<Ctx> !RefUnwindSafe for Compiler<Ctx>
impl<Ctx> !Send for Compiler<Ctx>
impl<Ctx> !Sync for Compiler<Ctx>
impl<Ctx> Unpin for Compiler<Ctx>where
Ctx: Unpin,
impl<Ctx> !UnwindSafe for Compiler<Ctx>
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