We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a207bf0 commit 218883aCopy full SHA for 218883a
library/core/src/char/convert.rs
@@ -23,7 +23,13 @@ pub(super) const fn from_u32(i: u32) -> Option<char> {
23
#[must_use]
24
pub(super) const unsafe fn from_u32_unchecked(i: u32) -> char {
25
// SAFETY: the caller must guarantee that `i` is a valid char value.
26
- if cfg!(debug_assertions) { char::from_u32(i).const_unwrap() } else { unsafe { transmute(i) } }
+ unsafe {
27
+ assert_unsafe_precondition!(
28
+ "invalid value for `char`",
29
+ (i: u32) => char_try_from_u32(i).is_ok()
30
+ );
31
+ transmute(i)
32
+ }
33
}
34
35
#[stable(feature = "char_convert", since = "1.13.0")]
0 commit comments