1
Fork 0

Stabilize const_panic

This commit is contained in:
Jacob Pratt 2021-10-04 00:33:43 -04:00
parent e737694a4d
commit bce8621983
No known key found for this signature in database
GPG key ID: B80E19E4662B5AA4
51 changed files with 100 additions and 229 deletions

View file

@ -124,7 +124,9 @@ macro_rules! newtype_index {
#[inline]
$v const fn from_usize(value: usize) -> Self {
// FIXME: replace with `assert!(value <= ($max as usize));` once `const_panic` is stable
#[cfg(not(bootstrap))]
assert!(value <= ($max as usize));
#[cfg(bootstrap)]
[()][(value > ($max as usize)) as usize];
unsafe {
Self::from_u32_unchecked(value as u32)
@ -133,7 +135,9 @@ macro_rules! newtype_index {
#[inline]
$v const fn from_u32(value: u32) -> Self {
// FIXME: replace with `assert!(value <= $max);` once `const_panic` is stable
#[cfg(not(bootstrap))]
assert!(value <= $max);
#[cfg(bootstrap)]
[()][(value > $max) as usize];
unsafe {
Self::from_u32_unchecked(value)