Use safe NonZero constructor instead of an explicit null check

This commit is contained in:
Simon Sapin 2018-01-22 13:26:04 +01:00
parent 10ec5a2bb0
commit b78ac6ba6a
4 changed files with 6 additions and 10 deletions

View file

@ -105,8 +105,7 @@ impl<T: DomObject + JSTraceable + Iterable> IterableIterator<T> {
};
self.index.set(index + 1);
result.map(|_| {
assert!(!rval.is_null());
unsafe { NonNull::new_unchecked(rval.get()) }
NonNull::new(rval.get()).expect("got a null pointer")
})
}
}