Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#![cfg_attr(not(test), no_std)]

use core::{
borrow::{Borrow, BorrowMut},
cmp::Ordering,
fmt::{Debug, Display},
hash::{Hash, Hasher},
Expand Down Expand Up @@ -144,6 +145,44 @@ where
}
}

impl<A, T> Borrow<T> for Aligned<A, T>
where
A: sealed::Alignment,
{
fn borrow(&self) -> &T {
&self.value
}
}

impl<A, T> BorrowMut<T> for Aligned<A, T>
where
A: sealed::Alignment,
{
fn borrow_mut(&mut self) -> &mut T {
&mut self.value
}
}

impl<A, T> Borrow<[<Aligned<A, T> as AsSlice>::Element]> for Aligned<A, T>
where
A: sealed::Alignment,
Aligned<A, T>: AsSlice,
{
fn borrow(&self) -> &[<Aligned<A, T> as AsSlice>::Element] {
self.as_slice()
}
}

impl<A, T> BorrowMut<[<Aligned<A, T> as AsSlice>::Element]> for Aligned<A, T>
where
A: sealed::Alignment,
Aligned<A, T>: AsMutSlice,
{
fn borrow_mut(&mut self) -> &mut [<Aligned<A, T> as AsSlice>::Element] {
self.as_mut_slice()
}
}

impl<A, T> Clone for Aligned<A, T>
where
A: sealed::Alignment,
Expand Down