Aside from Duration, are there any other `const fn`s in stable?


#1

I was kind of surprised to see const D: Duration = Duration::from_millis(...) actually work on stable. Given that const_fn hasn’t been stabilized yet, I figured this wouldn’t be possible.

Are there any other instances of const functions in the standard library, available on stable?


#2

There are several in std::mem. A couple others that spring to mind:

  • Cell::new()/RefCell::new()
  • AtomicUsize::new()

I’m sure there are others.

std can use unstable features internally so const_fn being unstable isn’t a blocker for it.