Skip to content

itemis/static_leak

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

static_leak

crates.io Build Status docs.rs codecov badge License: MIT License: Apache 2.0

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:

  • std
  • async-std
  • spin

About

No description, website, or topics provided.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages