Checked native dynamic library loading for MoonBit.
import {
"Nanaloveyuki/dynlib@0.1.0",
}let library = match @dynlib.load("example-library") {
Ok(value) => value
Err(error) => abort("load failed: \{error}")
}
let symbol = match library.resolve("example_symbol") {
Ok(value) => value
Err(error) => abort("symbol missing: \{error}")
}
let address = match symbol.address() {
Ok(value) => value
Err(error) => abort("library was closed: \{error}")
}
// Use address only with an explicit, ABI-correct native binding.
ignore(address)ignore(library.close())pub struct Library {
// private fields
}pub struct Symbol {
// private fields
}Checked native dynamic library loading for MoonBit.