File tree Expand file tree Collapse file tree 1 file changed +2
-3
lines changed Expand file tree Collapse file tree 1 file changed +2
-3
lines changed Original file line number Diff line number Diff line change @@ -121,16 +121,15 @@ pub trait Align {
121
121
/// is aligned. Returns `None` if no element of the buffer is
122
122
/// aligned.
123
123
fn align_buf ( buf : & mut [ u8 ] ) -> Option < & mut [ u8 ] > {
124
- let addr = buf. as_ptr ( ) as usize ;
125
- let offset = Self :: offset_up_to_alignment ( addr) ;
124
+ let offset = buf. as_ptr ( ) . align_offset ( Self :: alignment ( ) ) ;
126
125
buf. get_mut ( offset..)
127
126
}
128
127
129
128
/// Assert that some storage is correctly aligned for this type
130
129
fn assert_aligned ( storage : & mut [ u8 ] ) {
131
130
if !storage. is_empty ( ) {
132
131
assert_eq ! (
133
- ( storage. as_ptr( ) as usize ) % Self :: alignment( ) ,
132
+ storage. as_ptr( ) . align_offset ( Self :: alignment( ) ) ,
134
133
0 ,
135
134
"The provided storage is not correctly aligned for this type"
136
135
)
You can’t perform that action at this time.
0 commit comments