Use checked NonZero constructor in obligation forest NodeIndex

… to remove an `unsafe` block.
This commit is contained in:
Simon Sapin 2017-07-17 14:30:47 +02:00
parent 938552a228
commit 13d17adf60

View File

@ -19,7 +19,7 @@ pub struct NodeIndex {
impl NodeIndex {
pub fn new(value: usize) -> NodeIndex {
assert!(value < (u32::MAX as usize));
unsafe { NodeIndex { index: NonZero::new_unchecked((value as u32) + 1) } }
NodeIndex { index: NonZero::new((value as u32) + 1).unwrap() }
}
pub fn get(self) -> usize {