# Function rustc_unicode::char::from_u32_unchecked 1.5.0 [−] [src]

    pub unsafe fn from_u32_unchecked(i: u32) -> char

Converts a `u32` to a `char`, ignoring validity.

Note that all `char`s are valid `u32`s, and can be casted to one with `as`:

fn main() { let c = '💯'; let i = c as u32; assert_eq!(128175, i); }

    let c = '💯';
    let i = c as u32;

    assert_eq!(128175, i);

However, the reverse is not true: not all valid `u32`s are valid `char`s. `from_u32_unchecked()` will ignore this, and blindly cast to `char`, possibly creating an invalid one.

# Safety

This function is unsafe, as it may construct invalid `char` values.

For a safe version of this function, see the `from_u32()` function.

# Examples

Basic usage:

fn main() { use std::char; let c = unsafe { char::from_u32_unchecked(0x2764) }; assert_eq!('❤', c); }

    use std::char;

    let c = unsafe { char::from_u32_unchecked(0x2764) };

    assert_eq!('❤', c);

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result
+
  Collapse/expand all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)