nagisa / rust_libloading

Bindings around the platform's dynamic library loading primitives with greatly improved memory safety.
https://docs.rs/libloading
ISC License
1.22k stars 100 forks source link

use once_cell trouble #122

Open JonyTony opened 1 year ago

JonyTony commented 1 year ago

I want to use libloading to share some static variable by once_cell, but it is still None after I change it. like this:

let cell = value_from_lib();
cell.set(10).unwrap();
let val = cell.get();
assert!(val.is_some());
let cell = value_from_lib();
let val = cell.get();
assert!(val.is_none());

my static variable like this:

#[no_mangle]
pub static STATIC_VALUE: OnceCell<i32> = OnceCell::new();