Simple dependent types in const contexts?

I think the answer is to use unwrap, but to force it at compile-time:

thread::available_parallelism().unwrap_or(const { NonZeroUsize::new_unchecked(1).unwrap() })

using inline_const - The Rust Unstable Book.

9 Likes