@@ -143,11 +143,11 @@ impl CStr8 {
143
143
#[ must_use]
144
144
pub unsafe fn from_ptr < ' ptr > ( ptr : * const Char8 ) -> & ' ptr Self {
145
145
let mut len = 0 ;
146
- while * ptr. add ( len) != NUL_8 {
146
+ while unsafe { * ptr. add ( len) } != NUL_8 {
147
147
len += 1
148
148
}
149
149
let ptr = ptr. cast :: < u8 > ( ) ;
150
- Self :: from_bytes_with_nul_unchecked ( slice:: from_raw_parts ( ptr, len + 1 ) )
150
+ unsafe { Self :: from_bytes_with_nul_unchecked ( slice:: from_raw_parts ( ptr, len + 1 ) ) }
151
151
}
152
152
153
153
/// Creates a CStr8 reference from bytes.
@@ -171,7 +171,7 @@ impl CStr8 {
171
171
/// null-terminated string, with no interior null bytes.
172
172
#[ must_use]
173
173
pub const unsafe fn from_bytes_with_nul_unchecked ( chars : & [ u8 ] ) -> & Self {
174
- & * ( ptr:: from_ref ( chars) as * const Self )
174
+ unsafe { & * ( ptr:: from_ref ( chars) as * const Self ) }
175
175
}
176
176
177
177
/// Returns the inner pointer to this CStr8.
@@ -352,11 +352,11 @@ impl CStr16 {
352
352
#[ must_use]
353
353
pub unsafe fn from_ptr < ' ptr > ( ptr : * const Char16 ) -> & ' ptr Self {
354
354
let mut len = 0 ;
355
- while * ptr. add ( len) != NUL_16 {
355
+ while unsafe { * ptr. add ( len) } != NUL_16 {
356
356
len += 1
357
357
}
358
358
let ptr = ptr. cast :: < u16 > ( ) ;
359
- Self :: from_u16_with_nul_unchecked ( slice:: from_raw_parts ( ptr, len + 1 ) )
359
+ unsafe { Self :: from_u16_with_nul_unchecked ( slice:: from_raw_parts ( ptr, len + 1 ) ) }
360
360
}
361
361
362
362
/// Creates a `&CStr16` from a u16 slice, stopping at the first nul character.
@@ -405,7 +405,7 @@ impl CStr16 {
405
405
/// null-terminated string, with no interior null characters.
406
406
#[ must_use]
407
407
pub const unsafe fn from_u16_with_nul_unchecked ( codes : & [ u16 ] ) -> & Self {
408
- & * ( ptr:: from_ref ( codes) as * const Self )
408
+ unsafe { & * ( ptr:: from_ref ( codes) as * const Self ) }
409
409
}
410
410
411
411
/// Creates a `&CStr16` from a [`Char16`] slice, stopping at the first nul character.
@@ -455,7 +455,7 @@ impl CStr16 {
455
455
#[ must_use]
456
456
pub const unsafe fn from_char16_with_nul_unchecked ( chars : & [ Char16 ] ) -> & Self {
457
457
let ptr: * const [ Char16 ] = chars;
458
- & * ( ptr as * const Self )
458
+ unsafe { & * ( ptr as * const Self ) }
459
459
}
460
460
461
461
/// Convert a [`&str`] to a `&CStr16`, backed by a buffer.
0 commit comments