@@ -38,7 +38,26 @@ use core::{
3838
3939use as_slice:: { AsMutSlice , AsSlice } ;
4040
41- mod sealed;
41+ /// A marker trait for an alignment value.
42+ pub trait Alignment : Copy + sealed:: Sealed { }
43+
44+ impl Alignment for A2 { }
45+ impl Alignment for A4 { }
46+ impl Alignment for A8 { }
47+ impl Alignment for A16 { }
48+ impl Alignment for A32 { }
49+ impl Alignment for A64 { }
50+
51+ mod sealed {
52+ pub trait Sealed { }
53+
54+ impl Sealed for super :: A2 { }
55+ impl Sealed for super :: A4 { }
56+ impl Sealed for super :: A8 { }
57+ impl Sealed for super :: A16 { }
58+ impl Sealed for super :: A32 { }
59+ impl Sealed for super :: A64 { }
60+ }
4261
4362/// 2-byte alignment
4463#[ derive( Clone , Copy ) ]
@@ -91,7 +110,7 @@ pub const fn Aligned<A, T>(value: T) -> Aligned<A, T> {
91110
92111impl < A , T > ops:: Deref for Aligned < A , T >
93112where
94- A : sealed :: Alignment ,
113+ A : Alignment ,
95114 T : ?Sized ,
96115{
97116 type Target = T ;
@@ -103,7 +122,7 @@ where
103122
104123impl < A , T > ops:: DerefMut for Aligned < A , T >
105124where
106- A : sealed :: Alignment ,
125+ A : Alignment ,
107126 T : ?Sized ,
108127{
109128 fn deref_mut ( & mut self ) -> & mut T {
@@ -113,7 +132,7 @@ where
113132
114133impl < A , T > ops:: Index < ops:: RangeTo < usize > > for Aligned < A , [ T ] >
115134where
116- A : sealed :: Alignment ,
135+ A : Alignment ,
117136{
118137 type Output = Aligned < A , [ T ] > ;
119138
@@ -124,7 +143,7 @@ where
124143
125144impl < A , T > AsSlice for Aligned < A , T >
126145where
127- A : sealed :: Alignment ,
146+ A : Alignment ,
128147 T : AsSlice ,
129148{
130149 type Element = T :: Element ;
@@ -136,7 +155,7 @@ where
136155
137156impl < A , T > AsMutSlice for Aligned < A , T >
138157where
139- A : sealed :: Alignment ,
158+ A : Alignment ,
140159 T : AsMutSlice ,
141160{
142161 fn as_mut_slice ( & mut self ) -> & mut [ T :: Element ] {
@@ -146,7 +165,7 @@ where
146165
147166impl < A , T > Clone for Aligned < A , T >
148167where
149- A : sealed :: Alignment ,
168+ A : Alignment ,
150169 T : Clone ,
151170{
152171 fn clone ( & self ) -> Self {
@@ -159,14 +178,14 @@ where
159178
160179impl < A , T > Copy for Aligned < A , T >
161180where
162- A : sealed :: Alignment ,
181+ A : Alignment ,
163182 T : Copy ,
164183{
165184}
166185
167186impl < A , T > Default for Aligned < A , T >
168187where
169- A : sealed :: Alignment ,
188+ A : Alignment ,
170189 T : Default ,
171190{
172191 fn default ( ) -> Self {
@@ -179,7 +198,7 @@ where
179198
180199impl < A , T > Debug for Aligned < A , T >
181200where
182- A : sealed :: Alignment ,
201+ A : Alignment ,
183202 T : Debug ,
184203{
185204 fn fmt ( & self , f : & mut core:: fmt:: Formatter < ' _ > ) -> core:: fmt:: Result {
@@ -189,7 +208,7 @@ where
189208
190209impl < A , T > Display for Aligned < A , T >
191210where
192- A : sealed :: Alignment ,
211+ A : Alignment ,
193212 T : Display ,
194213{
195214 fn fmt ( & self , f : & mut core:: fmt:: Formatter < ' _ > ) -> core:: fmt:: Result {
@@ -199,7 +218,7 @@ where
199218
200219impl < A , T > PartialEq for Aligned < A , T >
201220where
202- A : sealed :: Alignment ,
221+ A : Alignment ,
203222 T : PartialEq ,
204223{
205224 fn eq ( & self , other : & Self ) -> bool {
@@ -209,14 +228,14 @@ where
209228
210229impl < A , T > Eq for Aligned < A , T >
211230where
212- A : sealed :: Alignment ,
231+ A : Alignment ,
213232 T : Eq ,
214233{
215234}
216235
217236impl < A , T > Hash for Aligned < A , T >
218237where
219- A : sealed :: Alignment ,
238+ A : Alignment ,
220239 T : Hash ,
221240{
222241 fn hash < H : Hasher > ( & self , state : & mut H ) {
@@ -226,7 +245,7 @@ where
226245
227246impl < A , T > Ord for Aligned < A , T >
228247where
229- A : sealed :: Alignment ,
248+ A : Alignment ,
230249 T : Ord ,
231250{
232251 fn cmp ( & self , other : & Self ) -> Ordering {
@@ -236,7 +255,7 @@ where
236255
237256impl < A , T > PartialOrd for Aligned < A , T >
238257where
239- A : sealed :: Alignment ,
258+ A : Alignment ,
240259 T : PartialOrd ,
241260{
242261 fn partial_cmp ( & self , other : & Self ) -> Option < Ordering > {
0 commit comments