diff --git a/src/lib.rs b/src/lib.rs index 0caeabc..1afb66a 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) }