1
Fork 0

add const_fn feature

This commit is contained in:
Niko Matsakis 2018-09-06 15:33:54 -04:00
parent e5e72f6666
commit ab43c1e9a4
2 changed files with 4 additions and 3 deletions

View file

@ -136,7 +136,7 @@ macro_rules! newtype_index {
]; ];
unsafe { unsafe {
$type::from_u32_unchecked(value) $type { private: value }
} }
} }
@ -153,13 +153,13 @@ macro_rules! newtype_index {
/// Extract value of this index as a usize. /// Extract value of this index as a usize.
#[inline] #[inline]
$v const fn as_u32(self) -> u32 { $v fn as_u32(self) -> u32 {
self.private self.private
} }
/// Extract value of this index as a u32. /// Extract value of this index as a u32.
#[inline] #[inline]
$v const fn as_usize(self) -> usize { $v fn as_usize(self) -> usize {
self.as_u32() as usize self.as_u32() as usize
} }
} }

View file

@ -24,6 +24,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
#![feature(box_syntax)] #![feature(box_syntax)]
#![feature(crate_visibility_modifier)] #![feature(crate_visibility_modifier)]
#![feature(core_intrinsics)] #![feature(core_intrinsics)]
#![feature(const_fn)]
#![feature(decl_macro)] #![feature(decl_macro)]
#![cfg_attr(stage0, feature(macro_vis_matcher))] #![cfg_attr(stage0, feature(macro_vis_matcher))]
#![feature(exhaustive_patterns)] #![feature(exhaustive_patterns)]