@@ -457,7 +457,7 @@ impl CStr16 {
457
457
pub fn from_unaligned_slice < ' buf > (
458
458
src : & UnalignedSlice < ' _ , u16 > ,
459
459
buf : & ' buf mut [ MaybeUninit < u16 > ] ,
460
- ) -> Result < & ' buf CStr16 , UnalignedCStr16Error > {
460
+ ) -> Result < & ' buf Self , UnalignedCStr16Error > {
461
461
// The input `buf` might be longer than needed, so get a
462
462
// subslice of the required length.
463
463
let buf = buf
@@ -469,7 +469,7 @@ impl CStr16 {
469
469
// Safety: `copy_buf` fully initializes the slice.
470
470
maybe_uninit_slice_assume_init_ref ( buf)
471
471
} ;
472
- CStr16 :: from_u16_with_nul ( buf) . map_err ( |e| match e {
472
+ Self :: from_u16_with_nul ( buf) . map_err ( |e| match e {
473
473
FromSliceWithNulError :: InvalidChar ( v) => UnalignedCStr16Error :: InvalidChar ( v) ,
474
474
FromSliceWithNulError :: InteriorNul ( v) => UnalignedCStr16Error :: InteriorNul ( v) ,
475
475
FromSliceWithNulError :: NotNulTerminated => UnalignedCStr16Error :: NotNulTerminated ,
@@ -524,7 +524,7 @@ impl CStr16 {
524
524
525
525
/// Returns if the string is empty. This ignores the null character.
526
526
#[ must_use]
527
- pub fn is_empty ( & self ) -> bool {
527
+ pub const fn is_empty ( & self ) -> bool {
528
528
self . num_chars ( ) == 0
529
529
}
530
530
@@ -566,7 +566,7 @@ impl CStr16 {
566
566
/// Returns the underlying bytes as slice including the terminating null
567
567
/// character.
568
568
#[ must_use]
569
- pub fn as_bytes ( & self ) -> & [ u8 ] {
569
+ pub const fn as_bytes ( & self ) -> & [ u8 ] {
570
570
unsafe { slice:: from_raw_parts ( self . 0 . as_ptr ( ) . cast ( ) , self . num_bytes ( ) ) }
571
571
}
572
572
}
@@ -593,7 +593,7 @@ impl From<&CStr16> for alloc::string::String {
593
593
. map ( u16:: from)
594
594
. map ( u32:: from)
595
595
. map ( |int| char:: from_u32 ( int) . expect ( "Should be encodable as UTF-8" ) )
596
- . collect :: < alloc :: string :: String > ( )
596
+ . collect :: < Self > ( )
597
597
}
598
598
}
599
599
@@ -615,8 +615,8 @@ impl<StrType: AsRef<str> + ?Sized> EqStrUntilNul<StrType> for CStr16 {
615
615
}
616
616
}
617
617
618
- impl AsRef < CStr16 > for CStr16 {
619
- fn as_ref ( & self ) -> & CStr16 {
618
+ impl AsRef < Self > for CStr16 {
619
+ fn as_ref ( & self ) -> & Self {
620
620
self
621
621
}
622
622
}
0 commit comments