#[init]Expand description
Designate a one-time library-load initialization function. See
init.
Designate an initialization function to run once, when this library is
loaded via Wolfram LibraryLink — distinct from [export], which wraps a
function called on every invocation from Wolfram.
The annotated function must take no arguments and return (). #[init]
can be applied to at most one function in a library, and a library isn’t
required to define one at all.
Behind the scenes, the macro generates a WolframLibrary_initialize() C
symbol — the well-known entry point the Wolfram Kernel calls
automatically when the library is loaded, before any exported function
runs.
§Panics
Panics inside the #[init] function are caught and reported to the Kernel
as an error code. If initialization panics, the Kernel will not load any
of this library’s other exported functions.
§Example
use wolfram_export::init;
#[init]
fn init_my_library() {
println!("library is now initialized");
}