# Zero-cost interior mutability - proposal

**URL:** <https://internals.rust-lang.org/t/zero-cost-interior-mutability-proposal/21814>\
**Category:** language design\
**Created:** [November 4, 2024, 4:04am UTC](https://internals.rust-lang.org/t/zero-cost-interior-mutability-proposal/21814 "2024-11-04T04:04:58Z")\
**Posts on this page:** 1\
**Showing post:** 40

<div class="post-metadata">

**Author:** ![scottmcm](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/scottmcm/32/2355_2.png) [@scottmcm](https://internals.rust-lang.org/u/scottmcm)\
**Post date:** [November 12, 2024, 1:32am UTC](https://internals.rust-lang.org/t/zero-cost-interior-mutability-proposal/21814/40 "2024-11-12T01:32:31Z")

</div>

> [@ryanavella](#):
>
> can be simulated with `&Cell<T>` where `T: Copy` or `T: Default` (assuming the `Default` impl is cheap)

You can couple this with temporaries & deref for a fun way of doing it, too.

I tossed together a sketch of it here, for example:

> <https://github.com/scottmcm/pawn-rs/blob/73ddbe1bf906ab14c749789ca191e169674c1b15/src/lib.rs#L53-L82>

---

_[View the full topic](https://internals.rust-lang.org/t/zero-cost-interior-mutability-proposal/21814)._
