| Crates.io | unchecked-refcell |
| lib.rs | unchecked-refcell |
| version | 0.2.2 |
| created_at | 2025-10-03 05:02:02.886187+00 |
| updated_at | 2025-10-05 09:48:22.253779+00 |
| description | A faster, drop-in replacement for RefCell in performance-critical code. |
| homepage | |
| repository | https://github.com/mcmah309/unchecked-refcell |
| max_upload_size | |
| id | 1866141 |
| size | 97,834 |
unchecked-refcellUncheckedRefCell is a drop-in alternative to core::cell::RefCell for performance-critical code where it is certain no borrowing rules are violated.
RefCell, enforcing Rust’s borrow rules.Enabling the
checkedfeature flag (disabled by default) forces borrow checking in release builds too. This is only intended for use with debugging.
It provides all the same APIs as RefCell, including:
borrow, borrow_mut, try_borrow, try_borrow_mut, replace, replace_with, swap, get_mut, take, etc.
checked — enable runtime borrow checking, identical to RefCell.debug_refcell — enables tracking of borrow origins for debugging purposes.Benchmarks comparing UncheckedRefCell with std::cell::RefCell (release build):
std_refcell_borrow: [2.5263 ms 2.5345 ms 2.5427 ms]
std_refcell_borrow_mut: [2.9351 ms 2.9377 ms 2.9406 ms]
unchecked_refcell_borrow: [677.66 µs 678.54 µs 679.50 µs]
unchecked_refcell_borrow_mut: [1.0260 ms 1.0268 ms 1.0276 ms]
In release builds without
checked,UncheckedRefCellis roughly 2–4x faster thanRefCell.