Skip to main content

cached_global_func

Macro cached_global_func 

Source
macro_rules! cached_global_func {
    ($name:literal) => { ... };
}
Expand description

Look up a registered global Function by name once, and keep it for the process: a &'static Function.

Each call site has its own cache, which later calls read without a lock. Use it for a function that must be registered, such as a built-in one; it panics, naming the function, if the function is not. See also Function::get_global, which returns an error instead.

ยงExamples

use tvm_ffi::{cached_global_func, Array};

let array = cached_global_func!("ffi.Array").call_tuple((1_i64, 2_i64))?;
assert_eq!(Array::<i64>::try_from(array)?.len(), 2);