Struct snek::Symbol
[−]
[src]
pub struct Symbol<'a> { /* fields omitted */ }
This provides an interface around a symbol loaded from a
dynamic library. This should not be constructed manually,
but returned from Snek::symbol
or used internally via the snek!
macro.
Methods
impl<'a> Symbol<'a>
[src]
fn new(symbol: *mut c_void) -> Symbol<'a>
Construct a new Symbol
wrapping a symbol. This should not be used
manually, however is public to allow access from the
snek!
macro.
unsafe fn with<F, T, U>(&self, f: F) -> U where
F: Fn(T) -> U,
F: Fn(T) -> U,
Use the symbol as if it was a certain type. There is no way of checking that the symbol is of the specified type, so this function should be used with care.
Safety
When calling this function, ensure the type of the symbol is actually the type you say it is.
Example
let result: c_int = unsafe { symbol.with(|add: extern fn(c_int, c_int) -> c_int| add(3, 7)) };