diff --git a/src/lib.rs b/src/lib.rs index acc016c..ddd5421 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -30,6 +30,7 @@ #![cfg_attr(not(test), no_std)] use core::{ + borrow::{Borrow, BorrowMut}, cmp::Ordering, fmt::{Debug, Display}, hash::{Hash, Hasher}, @@ -144,6 +145,44 @@ where } } +impl Borrow for Aligned +where + A: sealed::Alignment, +{ + fn borrow(&self) -> &T { + &self.value + } +} + +impl BorrowMut for Aligned +where + A: sealed::Alignment, +{ + fn borrow_mut(&mut self) -> &mut T { + &mut self.value + } +} + +impl Borrow<[ as AsSlice>::Element]> for Aligned +where + A: sealed::Alignment, + Aligned: AsSlice, +{ + fn borrow(&self) -> &[ as AsSlice>::Element] { + self.as_slice() + } +} + +impl BorrowMut<[ as AsSlice>::Element]> for Aligned +where + A: sealed::Alignment, + Aligned: AsMutSlice, +{ + fn borrow_mut(&mut self) -> &mut [ as AsSlice>::Element] { + self.as_mut_slice() + } +} + impl Clone for Aligned where A: sealed::Alignment,