# Compile time assert

**URL:** <https://internals.rust-lang.org/t/compile-time-assert/6751>\
**Category:** compiler\
**Created:** [February 12, 2018, 12:17pm UTC](https://internals.rust-lang.org/t/compile-time-assert/6751 "2018-02-12T12:17:52Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![davemilter](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/davemilter/32/3493_2.png) [@davemilter](https://internals.rust-lang.org/u/davemilter)\
**Post date:** [February 12, 2018, 11:46pm UTC](https://internals.rust-lang.org/t/compile-time-assert/6751/3 "2018-02-12T23:46:20Z")

</div>

> [@sfackler](#):
>
> You can abuse transmute to do this at compile time if you want:
> 
> fn \_size\_check() { unsafe { mem::transmute::\<usize, [u8; 4]\>(0); } }

Yes, I know about this trick, there is also [static\_assertions crate](https://crates.io/crates/static_assertions) that provides nice wrapper around this or similar trick.

But it would be great to have it inside `std` or compiler.

---

_[View the full topic](https://internals.rust-lang.org/t/compile-time-assert/6751)._
