Hacker News new | ask | show | jobs
by steveklabnik 2037 days ago
const fns are not inherently evaluated at compile time, so that would be a misnomer.
1 comments

Maybe `pure`. Then it is fairly straightforward to explain that the computation of `const` values must be `pure`.
Fun fact: Rust did use "pure" a very long time ago... https://news.ycombinator.com/item?id=24295941

It has its own challenges. Consider:

  const fn foo(x: &mut i32) {
      *x += 1;
  }
would you consider this function pure? I don't think many would. Also, it may be pure given Rust's semantics, but it kinda goes against the intuitive, usual way people talk about purity, so that makes it hard.

(This is not yet stable in Rust, but will be.)