3 unstable releases
0.3.1 | May 28, 2022 |
---|---|
0.3.0 | May 28, 2022 |
0.2.0 | May 28, 2022 |
0.1.0 |
|
#18 in #debug-mode
12KB
243 lines
maybe_atomic_refcell
AtomicRefCell
for debug
mode and UnsafeCell
in release
mode.
Motivation
AtomicRefCell
performs an atomic memory access at runtime to validate borrowing. While
this is an excellent way to validate code and ensure safety, it is an expensive
operation. This crate delegates to AtomicRefCell
in debug
mode and uses UnsafeCell
to
emulate the same interface in release
mode, minus the runtime overhead.
Features
safe
enables unconditional runtime checks, good for validating inrelease
mode
Limitations
- No try-borrows, as they are impossible to (properly) implement without overhead
borrow
andborrow_mut
areunsafe
(despite being safe indebug
mode)- No
PartialEq
,Eq
,PartialOrd
,Ord
, etc. due to the above
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Dependencies
~20KB