diff --git a/src/lib.rs b/src/lib.rs index 0caeabc..05f70fd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -159,11 +159,13 @@ impl Aligned where A: Alignment, { + #[inline(always)] fn is_index_aligned(index: usize) -> bool { use core::mem::size_of; (index * size_of::()) % A::ALIGN == 0 } + #[inline(always)] fn check_start_index(index: usize) { if !Self::is_index_aligned(index) { panic!("Unaligned start index"); @@ -177,6 +179,7 @@ where { type Output = Aligned; + #[inline(always)] fn index(&self, range: ops::RangeFrom) -> &Aligned { Self::check_start_index(range.start); unsafe { &*(&self.value[range] as *const [T] as *const Aligned) } @@ -211,6 +214,7 @@ where { type Output = Aligned; + #[inline(always)] fn index(&self, range: ops::RangeInclusive) -> &Aligned { Self::check_start_index(*range.start()); unsafe { &*(&self.value[range] as *const [T] as *const Aligned) } @@ -223,6 +227,7 @@ where { type Output = Aligned; + #[inline(always)] fn index(&self, range: ops::Range) -> &Aligned { Self::check_start_index(range.start); unsafe { &*(&self.value[range] as *const [T] as *const Aligned) } @@ -244,6 +249,7 @@ impl ops::IndexMut> for Aligned where A: Alignment, { + #[inline(always)] fn index_mut(&mut self, range: ops::RangeFrom) -> &mut Aligned { Self::check_start_index(range.start); unsafe { &mut *(&mut self.value[range] as *mut [T] as *mut Aligned) } @@ -272,6 +278,7 @@ impl ops::IndexMut> for Aligned where A: Alignment, { + #[inline(always)] fn index_mut(&mut self, range: ops::RangeInclusive) -> &mut Aligned { Self::check_start_index(*range.start()); unsafe { &mut *(&mut self.value[range] as *mut [T] as *mut Aligned) } @@ -282,6 +289,7 @@ impl ops::IndexMut> for Aligned where A: Alignment, { + #[inline(always)] fn index_mut(&mut self, range: ops::Range) -> &mut Aligned { Self::check_start_index(range.start); unsafe { &mut *(&mut self.value[range] as *mut [T] as *mut Aligned) } @@ -390,7 +398,7 @@ where } } -impl Debug for Aligned +impl Debug for Aligned where A: Alignment, T: Debug, @@ -400,7 +408,7 @@ where } } -impl Display for Aligned +impl Display for Aligned where A: Alignment, T: Display, @@ -410,7 +418,7 @@ where } } -impl PartialEq for Aligned +impl PartialEq for Aligned where A: Alignment, T: PartialEq, @@ -420,14 +428,14 @@ where } } -impl Eq for Aligned +impl Eq for Aligned where A: Alignment, T: Eq, { } -impl Hash for Aligned +impl Hash for Aligned where A: Alignment, T: Hash, @@ -437,7 +445,7 @@ where } } -impl Ord for Aligned +impl Ord for Aligned where A: Alignment, T: Ord, @@ -447,7 +455,7 @@ where } } -impl PartialOrd for Aligned +impl PartialOrd for Aligned where A: Alignment, T: PartialOrd,