We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4512721 commit 52ed89aCopy full SHA for 52ed89a
src/libcore/char/convert.rs
@@ -99,7 +99,7 @@ pub fn from_u32(i: u32) -> Option<char> {
99
#[inline]
100
#[stable(feature = "char_from_unchecked", since = "1.5.0")]
101
pub unsafe fn from_u32_unchecked(i: u32) -> char {
102
- transmute(i)
+ if cfg!(debug_assertions) { char::from_u32(i).unwrap() } else { transmute(i) }
103
}
104
105
#[stable(feature = "char_convert", since = "1.13.0")]
@@ -218,7 +218,7 @@ impl TryFrom<u32> for char {
218
Err(CharTryFromError(()))
219
} else {
220
// SAFETY: checked that it's a legal unicode value
221
- Ok(unsafe { from_u32_unchecked(i) })
+ Ok(unsafe { transmute(i) })
222
223
224
0 commit comments