Thoughts on compile-time function evaluation and type systems (2018)(ralfj.de)
ralfj.de
Thoughts on compile-time function evaluation and type systems (2018)
https://www.ralfj.de/blog/2018/07/19/const.html
https://www.ralfj.de/blog/2018/07/19/const.html
> Lucky enough, Rust already has an answer to the need to side-step the type system in controlled ways: unsafe blocks. Comparing raw pointers is not allowed by the const type system because it is not const-safe, but just like we allow run-time-unsafe operations to be performed in unsafe blocks, we can allow const-unsafe operations as well. So, we should be able to write the following:
If this is ever introduced, I hope that one would be able to mark whether an unsafe block is used because a const-safety restriction (like comparing two pointers for equality) or runtime-safety restriction (all other uses of regular, runtime unsafe)
Like this:
edit: this same point was made in the Rust internals thread when the article was written, https://internals.rust-lang.org/t/thoughts-on-compile-time-f...