math_adapter/plugin/winit/
x2.rs1
2pub( crate ) mod private
8{
9 use core::mem::size_of;
10 use crate::prelude::*;
11 use crate::{ X2, ScalarInterface };
12
13 macro_rules! impl_x2_for
18 {
19 ( $Struct : path, $_0 : ident, $_1 : ident ) =>
20 {
21
22 impl< Scalar > X2NominalInterface for $Struct
23 where
24 Scalar : ScalarInterface,
25 {
26 type Scalar = Scalar;
27
28 #[ inline ]
29 fn _0( &self ) -> Self::Scalar
30 {
31 self.$_0
32 }
33
34 #[ inline ]
35 fn _1( &self ) -> Self::Scalar
36 {
37 self.$_1
38 }
39
40 }
41
42 impl< Scalar > X2BasicInterface for $Struct
43 where
44 Scalar : ScalarInterface,
45 {
46
47 #[ inline ]
48 fn make( _0 : Self::Scalar, _1 : Self::Scalar ) -> Self
49 {
50 Self::new( _0, _1 )
51 }
52
53 }
54
55 impl< Scalar > X2CanonicalInterface for $Struct
56 where
57 Scalar : ScalarInterface,
58 {
59
60 #[ inline ]
63 fn _0_ref( &self ) -> &Self::Scalar
64 {
65 &self.$_0
66 }
67
68 #[ inline ]
69 fn _1_ref( &self ) -> &Self::Scalar
70 {
71 &self.$_1
72 }
73
74 #[ inline ]
77 fn _0_mut( &mut self ) -> &mut Self::Scalar
78 {
79 &mut self.$_0
80 }
81
82 #[ inline ]
83 fn _1_mut( &mut self ) -> &mut Self::Scalar
84 {
85 &mut self.$_1
86 }
87
88 #[ inline ]
91 fn as_canonical( &self ) -> &X2< Self::Scalar >
92 {
93 debug_assert_eq!( size_of::< Self >(), size_of::< X2< Self::Scalar > >() );
94 unsafe
95 {
96 std::mem::transmute::< _, _ >( self )
97 }
98 }
99
100 #[ inline ]
101 fn as_canonical_mut( &mut self ) -> &mut X2< Self::Scalar >
102 {
103 debug_assert_eq!( size_of::< Self >(), size_of::< X2< Self::Scalar > >() );
104 unsafe
105 {
106 std::mem::transmute::< _, _ >( self )
107 }
108 }
109
110 }
111
112 };
113
114 }
115
116 impl_x2_for!( winit::dpi::PhysicalSize< Scalar >, width, height );
117 impl_x2_for!( winit::dpi::LogicalSize< Scalar >, width, height );
118 impl_x2_for!( winit::dpi::PhysicalPosition< Scalar >, x, y );
119 impl_x2_for!( winit::dpi::LogicalPosition< Scalar >, x, y );
120
121}
122
123crate::mod_interface!
126{
127}