# Mutable struct vs Ref in an immutable one?

**URL:** <https://discourse.julialang.org/t/mutable-struct-vs-ref-in-an-immutable-one/92846>\
**Category:** General Usage\
**Tags:** question, type, struct, mutable-structure\
**Created:** [January 12, 2023, 5:07am UTC](https://discourse.julialang.org/t/mutable-struct-vs-ref-in-an-immutable-one/92846 "2023-01-12T05:07:35Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![torrance](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/torrance/32/38990_2.png) [@torrance](https://discourse.julialang.org/u/torrance)\
**Post date:** [January 16, 2023, 4:24am UTC](https://discourse.julialang.org/t/mutable-struct-vs-ref-in-an-immutable-one/92846/4 "2023-01-16T04:24:34Z")

</div>

> [@vchuravy](#):
>
> A downside is the layout when the `A` and `B` are contained in other structures. As an example inside an array `A` can be stored inline whereas for `B` a reference will be stored.

@vchuravy This [touches on a question](https://discourse.julialang.org/t/on-arrays-with-inline-elements-vs-pointer-indirection/88211) I asked some time ago about determining when a type is stored inline in an array versus as pointers.

I understood that only `isbits` types were stored inline, and that therefore in this case `Struct A` would not be stored inline.

Is this wrong? And if so (as I asked in the other thread), how can I determine when a type will be stored inline or not?

---

_[View the full topic](https://discourse.julialang.org/t/mutable-struct-vs-ref-in-an-immutable-one/92846)._
