File tree 1 file changed +3
-0
lines changed
1 file changed +3
-0
lines changed Original file line number Diff line number Diff line change @@ -453,6 +453,7 @@ impl AsciiChar {
453
453
/// or returns `None` if it's too large.
454
454
#[ unstable( feature = "ascii_char" , issue = "110998" ) ]
455
455
#[ inline]
456
+ #[ ensures( |result| ( b <= 127 ) == ( result. is_some( ) && result. unwrap( ) as u8 == b) ) ]
456
457
pub const fn from_u8 ( b : u8 ) -> Option < Self > {
457
458
if b <= 127 {
458
459
// SAFETY: Just checked that `b` is in-range
@@ -470,6 +471,8 @@ impl AsciiChar {
470
471
/// `b` must be in `0..=127`, or else this is UB.
471
472
#[ unstable( feature = "ascii_char" , issue = "110998" ) ]
472
473
#[ inline]
474
+ #[ requires( b <= 127 ) ]
475
+ #[ ensures( |result| * result as u8 == b) ]
473
476
pub const unsafe fn from_u8_unchecked ( b : u8 ) -> Self {
474
477
// SAFETY: Our safety precondition is that `b` is in-range.
475
478
unsafe { transmute ( b) }
You can’t perform that action at this time.
0 commit comments