Struct arithmetic_eval::fns::Dbg
source · pub struct Dbg;
Expand description
Acts similarly to the dbg!
macro, outputting the argument(s) to stderr and returning
them. If a single argument is provided, it’s returned as-is; otherwise, the arguments
are wrapped into a tuple.
§Examples
let program = "dbg(1 + 2) > 2.5";
let program = Untyped::<F32Grammar>::parse_statements(program)?;
let module = ExecutableModule::new("test_dbg", &program)?;
let mut env = Environment::new();
env.insert_native_fn("dbg", fns::Dbg);
let value = module.with_env(&env)?.run()?;
// Should output `[test_assert:1:5] 1 + 2 = 3` to stderr.
assert_eq!(value, Value::Bool(true));
Trait Implementations§
source§impl<T: Display> NativeFn<T> for Dbg
impl<T: Display> NativeFn<T> for Dbg
source§fn evaluate(
&self,
args: Vec<SpannedValue<T>>,
ctx: &mut CallContext<'_, T>,
) -> EvalResult<T>
fn evaluate( &self, args: Vec<SpannedValue<T>>, ctx: &mut CallContext<'_, T>, ) -> EvalResult<T>
Executes the function on the specified arguments.
impl Copy for Dbg
Auto Trait Implementations§
impl Freeze for Dbg
impl RefUnwindSafe for Dbg
impl Send for Dbg
impl Sync for Dbg
impl Unpin for Dbg
impl UnwindSafe for Dbg
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
source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)