@@ -457,7 +457,7 @@ impl CStr16 {
457457 pub fn from_unaligned_slice < ' buf > (
458458 src : & UnalignedSlice < ' _ , u16 > ,
459459 buf : & ' buf mut [ MaybeUninit < u16 > ] ,
460- ) -> Result < & ' buf CStr16 , UnalignedCStr16Error > {
460+ ) -> Result < & ' buf Self , UnalignedCStr16Error > {
461461 // The input `buf` might be longer than needed, so get a
462462 // subslice of the required length.
463463 let buf = buf
@@ -469,7 +469,7 @@ impl CStr16 {
469469 // Safety: `copy_buf` fully initializes the slice.
470470 maybe_uninit_slice_assume_init_ref ( buf)
471471 } ;
472- CStr16 :: from_u16_with_nul ( buf) . map_err ( |e| match e {
472+ Self :: from_u16_with_nul ( buf) . map_err ( |e| match e {
473473 FromSliceWithNulError :: InvalidChar ( v) => UnalignedCStr16Error :: InvalidChar ( v) ,
474474 FromSliceWithNulError :: InteriorNul ( v) => UnalignedCStr16Error :: InteriorNul ( v) ,
475475 FromSliceWithNulError :: NotNulTerminated => UnalignedCStr16Error :: NotNulTerminated ,
@@ -524,7 +524,7 @@ impl CStr16 {
524524
525525 /// Returns if the string is empty. This ignores the null character.
526526 #[ must_use]
527- pub fn is_empty ( & self ) -> bool {
527+ pub const fn is_empty ( & self ) -> bool {
528528 self . num_chars ( ) == 0
529529 }
530530
@@ -566,7 +566,7 @@ impl CStr16 {
566566 /// Returns the underlying bytes as slice including the terminating null
567567 /// character.
568568 #[ must_use]
569- pub fn as_bytes ( & self ) -> & [ u8 ] {
569+ pub const fn as_bytes ( & self ) -> & [ u8 ] {
570570 unsafe { slice:: from_raw_parts ( self . 0 . as_ptr ( ) . cast ( ) , self . num_bytes ( ) ) }
571571 }
572572}
@@ -593,7 +593,7 @@ impl From<&CStr16> for alloc::string::String {
593593 . map ( u16:: from)
594594 . map ( u32:: from)
595595 . map ( |int| char:: from_u32 ( int) . expect ( "Should be encodable as UTF-8" ) )
596- . collect :: < alloc :: string :: String > ( )
596+ . collect :: < Self > ( )
597597 }
598598}
599599
@@ -615,8 +615,8 @@ impl<StrType: AsRef<str> + ?Sized> EqStrUntilNul<StrType> for CStr16 {
615615 }
616616}
617617
618- impl AsRef < CStr16 > for CStr16 {
619- fn as_ref ( & self ) -> & CStr16 {
618+ impl AsRef < Self > for CStr16 {
619+ fn as_ref ( & self ) -> & Self {
620620 self
621621 }
622622}
0 commit comments