# API to acquire arbitrarily initialized buffer?

**URL:** <https://internals.rust-lang.org/t/api-to-acquire-arbitrarily-initialized-buffer/13213>\
**Category:** Uncategorized\
**Created:** [October 15, 2020, 7:41pm UTC](https://internals.rust-lang.org/t/api-to-acquire-arbitrarily-initialized-buffer/13213 "2020-10-15T19:41:04Z")\
**Posts on this page:** 1\
**Showing post:** 17

<div class="post-metadata">

**Author:** ![RalfJung](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/ralfjung/32/2415_2.png) [@RalfJung](https://internals.rust-lang.org/u/RalfJung)\
**Post date:** [October 19, 2020, 10:30am UTC](https://internals.rust-lang.org/t/api-to-acquire-arbitrarily-initialized-buffer/13213/17 "2020-10-19T10:30:32Z")

</div>

> [@atagunov](#):
>
> I might be clueless but.. Compiling `let a = b` can end up with one of the following two results:
> 
> - `a : u8` , `b : mu8` =\> this ends up compiled into MIR as if it was `a = freeze(b)`
> - in all other cases same behavior as today treating `mu8` say as a shorthand for `MaybeUninit<u8>`

Oh, I somehow missed that `a: u8` here. So in generic code I could not even enter the first case.

Basically, to use Rust terminology, you are suggesting to add a _coercion_ from `mu8` to `u8` that performs a freeze. Sorry for misunderstanding.

In that case I do not see a reason for why that should be an implicit coercion, we might as well do

```rust
type mu8 = MaybeUninit<u8>;

impl mu8 {
  fn freeze(self) -> u8 { /* ... */ }
}

```

I do not think saving 9 characters for some very specific unsafe code is worth the extra coercion, and also this is a subtle operation that really should be performed explicitly rather than implicitly.

---

_[View the full topic](https://internals.rust-lang.org/t/api-to-acquire-arbitrarily-initialized-buffer/13213)._
