File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -482,6 +482,20 @@ impl u8 {
482
482
ascii:: Char :: from_u8 ( * self )
483
483
}
484
484
485
+ /// Converts this byte to an [ASCII character](ascii::Char), without
486
+ /// checking whether or not it's valid.
487
+ ///
488
+ /// # Safety
489
+ ///
490
+ /// This byte must be valid ASCII, or else this is UB.
491
+ #[ must_use]
492
+ #[ unstable( feature = "ascii_char" , issue = "110998" ) ]
493
+ #[ inline]
494
+ pub const unsafe fn as_ascii_unchecked ( & self ) -> ascii:: Char {
495
+ // SAFETY: the caller promised that this byte is ASCII.
496
+ unsafe { ascii:: Char :: from_u8_unchecked ( * self ) }
497
+ }
498
+
485
499
/// Makes a copy of the value in its ASCII upper case equivalent.
486
500
///
487
501
/// ASCII letters 'a' to 'z' are mapped to 'A' to 'Z',
You can’t perform that action at this time.
0 commit comments