File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change 1+ use std:: mem:: MaybeUninit ;
12use std:: { ptr, str, slice, fmt } ;
23use std:: ops:: Deref ;
34
@@ -6,7 +7,7 @@ pub const MAX_LEN: usize = 30;
67#[ derive( Clone , Copy ) ]
78pub struct Short {
89 len : u8 ,
9- value : [ u8 ; MAX_LEN ] ,
10+ value : [ MaybeUninit < u8 > ; MAX_LEN ] ,
1011}
1112
1213/// A `Short` is a small string, up to `MAX_LEN` bytes, that can be managed without
@@ -23,11 +24,11 @@ impl Short {
2324 #[ inline( always) ]
2425 pub unsafe fn from_slice ( slice : & str ) -> Self {
2526 let mut short = Short {
26- value : [ 0 ; MAX_LEN ] ,
27+ value : MaybeUninit :: uninit ( ) . assume_init ( ) ,
2728 len : slice. len ( ) as u8 ,
2829 } ;
2930
30- ptr:: copy_nonoverlapping ( slice. as_ptr ( ) , short. value . as_mut_ptr ( ) , slice. len ( ) ) ;
31+ ptr:: copy_nonoverlapping ( slice. as_ptr ( ) , short. value . as_mut_ptr ( ) as _ , slice. len ( ) ) ;
3132
3233 short
3334 }
@@ -37,7 +38,7 @@ impl Short {
3738 pub fn as_str ( & self ) -> & str {
3839 unsafe {
3940 str:: from_utf8_unchecked (
40- slice:: from_raw_parts ( self . value . as_ptr ( ) , self . len as usize )
41+ slice:: from_raw_parts ( self . value . as_ptr ( ) as _ , self . len as usize )
4142 )
4243 }
4344 }
You can’t perform that action at this time.
0 commit comments