# Random thought of the day: "magic cell", a Cell-like interface for all data

**URL:** <https://internals.rust-lang.org/t/random-thought-of-the-day-magic-cell-a-cell-like-interface-for-all-data/3916>\
**Category:** libs\
**Created:** [August 24, 2016, 11:22am UTC](https://internals.rust-lang.org/t/random-thought-of-the-day-magic-cell-a-cell-like-interface-for-all-data/3916 "2016-08-24T11:22:09Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![DanielKeep](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/danielkeep/32/1332_2.png) [@DanielKeep](https://internals.rust-lang.org/u/DanielKeep)\
**Post date:** [August 24, 2016, 12:16pm UTC](https://internals.rust-lang.org/t/random-thought-of-the-day-magic-cell-a-cell-like-interface-for-all-data/3916/4 "2016-08-24T12:16:26Z")

</div>

> [@dan\_t](#):
>
> I can see how code using MagicCell is easier to write but it will also most likely easier hide potential performance problems.

This would be my concern. It feels like a serious performance footgun: anyone who can't correctly pick between `Cell` and `RefCell` (where we can just say "try `Cell`, falling back to `RefCell` if that doesn't work) seems _unlikely_ to correctly pick between `MagicCell` and `RefCell`, which requires them to now _also_ consider `Clone` performance.

What about using specialisation to have a `RefCell`-like type which, if it's used with a `Copy` type, also gains `get`, `set`, and loses the flag?

---

_[View the full topic](https://internals.rust-lang.org/t/random-thought-of-the-day-magic-cell-a-cell-like-interface-for-all-data/3916)._
