| Crates.io | static_leak |
| lib.rs | static_leak |
| version | 0.1.0 |
| created_at | 2022-11-10 16:43:01.09275+00 |
| updated_at | 2022-11-10 16:43:01.09275+00 |
| description | Leak references with static lifetimes from static Mutexes and RwLocks |
| homepage | |
| repository | https://github.com/itemis/static_leak/ |
| max_upload_size | |
| id | 712233 |
| size | 29,259 |
This crate extends Mutexes and RwLocks wrapping references with static lifetimes to leak these raw underlying references.
This can be useful to safely obtain a static mutable reference without using any unsafe code when interacting with a legacy C project via FFI.
lazy_static! {
static ref VAR: RwLock<i8> = RwLock::new(42);
}
fn bar(_: &'static mut i8) {}
fn main() {
bar(RwLockWriteGuard::leak(VAR.write().unwrap()));
}
This crate supports implementations from the following crates, which are activated through the respective feature flags: