Skip to content

Commit

Permalink
Add forward-compatible AsRef
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski committed Aug 4, 2024
1 parent a534116 commit 51d0fc3
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/legacy/internal/convert/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,24 @@ impl<T> AsRef<[T; 4]> for RGBA<T> {
}
}

impl<T> AsRef<[T; 4]> for ARGB<T> {
fn as_ref(&self) -> &[T; 4] {
unsafe { &*(self as *const Self).cast() }
}
}

impl<T> AsRef<[T; 4]> for BGRA<T> {
fn as_ref(&self) -> &[T; 4] {
unsafe { &*(self as *const Self).cast() }
}
}

impl<T> AsRef<[T; 4]> for ABGR<T> {
fn as_ref(&self) -> &[T; 4] {
unsafe { &*(self as *const Self).cast() }
}
}

#[cfg(not(feature = "unstable-experimental"))]
impl<T> AsRef<T> for GrayAlpha<T> {
#[inline(always)]
Expand Down

0 comments on commit 51d0fc3

Please sign in to comment.