From 7b06715299bf8b941c40fc04acccb760766bf4e7 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Tue, 24 Mar 2020 11:21:09 +0800 Subject: [PATCH] FIX - Errors in no_std. --- examples/no_std.rs | 6 +++++- src/api.rs | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/examples/no_std.rs b/examples/no_std.rs index 9f51f586..32cf14a2 100644 --- a/examples/no_std.rs +++ b/examples/no_std.rs @@ -7,7 +7,11 @@ fn main() -> Result<(), EvalAltResult> { let result = engine.eval::("40 + 2")?; - println!("Answer: {}", 42); + #[cfg(not(feature = "no_std"))] + println!("Answer: {}", result); + + #[cfg(feature = "no_std")] + assert_eq!(result, 42); Ok(()) } diff --git a/src/api.rs b/src/api.rs index 208f311c..ef1b0091 100644 --- a/src/api.rs +++ b/src/api.rs @@ -177,7 +177,7 @@ impl<'e> Engine<'e> { name: &str, callback: impl Fn(&mut T) -> U + 'static, ) { - let get_fn_name = format!("{}{}", FUNC_GETTER, name); + let get_fn_name = FUNC_GETTER.to_string() + name; self.register_fn(&get_fn_name, callback); } @@ -219,7 +219,7 @@ impl<'e> Engine<'e> { name: &str, callback: impl Fn(&mut T, U) -> () + 'static, ) { - let set_fn_name = format!("{}{}", FUNC_SETTER, name); + let set_fn_name = FUNC_SETTER.to_string() + name; self.register_fn(&set_fn_name, callback); }