Iterator constructor improvements, along the lines of the last commit
@@ -514,35 +514,29 @@ impl<T, const N: usize> StaticVec<T, { N }> {
/// inhabited area.
#[inline(always)]
pub fn iter<'a>(&'a self) -> StaticVecIterConst<'a, T> {
- unsafe {
StaticVecIterConst::<'a, T> {
start: self.as_ptr(),
- end: if intrinsics::size_of::<T>() == 0 {
- (self.as_ptr() as *const u8).wrapping_add(self.length) as *const T
- } else {
- self.as_ptr().add(self.length)
+ end: match intrinsics::size_of::<T>() {
+ 0 => (self.as_ptr() as *const u8).wrapping_add(self.length) as *const T,
+ _ => unsafe { self.as_ptr().add(self.length) },
},
marker: PhantomData,
}
}
- }
/// Returns a [StaticVecIterMut](crate::iterators::StaticVecIterMut) over the StaticVec's
/// inhabited area.
#[inline(always)]
pub fn iter_mut<'a>(&'a mut self) -> StaticVecIterMut<'a, T> {
- unsafe {
StaticVecIterMut::<'a, T> {
start: self.as_mut_ptr(),
- end: if intrinsics::size_of::<T>() == 0 {
- (self.as_mut_ptr() as *mut u8).wrapping_add(self.length) as *mut T
- } else {
- self.as_mut_ptr().add(self.length)
+ end: match intrinsics::size_of::<T>() {
+ 0 => (self.as_mut_ptr() as *mut u8).wrapping_add(self.length) as *mut T,
+ _ => unsafe { self.as_mut_ptr().add(self.length) },
},
marker: PhantomData,
}
}
- }
/// Returns a separate, stable-sorted StaticVec of the contents of the
/// StaticVec's inhabited area without modifying the original data.
