rgb/formats/
gray_alpha.rs1use crate::formats::gray_a::GrayA;
2use core::ops::Deref;
3
4#[repr(C)]
5#[cfg_attr(feature = "unstable-experimental", deprecated(note = "renamed to GrayA"))]
6#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7#[cfg_attr(feature = "defmt-03", derive(defmt::Format))]
8#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, Ord, PartialOrd, Hash)]
9#[allow(non_camel_case_types)]
14pub struct GrayAlpha_v08<T, A = T>(
15 pub T,
19 pub A,
21);
22
23impl<T: Copy> GrayAlpha_v08<T> {
24 pub fn value(self) -> T {
28 self.0
29 }
30
31 pub fn value_mut(&mut self) -> &mut T {
35 &mut self.0
36 }
37}
38
39impl<T, A> Deref for GrayAlpha_v08<T, A> {
40 type Target = GrayA<T, A>;
41
42 fn deref(&self) -> &GrayA<T, A> {
44 unsafe {
45 &*(self as *const Self as *const GrayA::<T, A>)
46 }
47 }
48}
49
50#[test]
51fn swizzle() {
52 let g = GrayAlpha_v08(10u8, 20u8);
53 assert_eq!(10, g.v);
54 assert_eq!(20, g.a);
55}