nova-interpreter 0.1.1

An interpreter library for the nova language
Documentation
pub mod interner;

use super::engine::state::State;

/// Helper type for function that can return an error
pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;

/// Helper type for builtin functions to pass the engine state
pub type PrimitiveFn = Box<dyn Fn(&mut State, usize)>;

/// Run a function and return both the function results
/// and the amount of time it took to run the function
#[macro_export]
macro_rules! time_fn {
    ($f:block) => {{
        let pre_run_time = std::time::Instant::now();

        let result = $f;

        let post_run_time = std::time::Instant::now();

        let duration = post_run_time - pre_run_time;

        (result, duration)
    }};
}