# Function std::char::from_u32 1.0.0 [−] [src]

    pub fn from_u32(i: u32) -> Option<char>

Converts a `u32` to a `char`.

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

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

    assert_eq!(128175, i);Run

However, the reverse is not true: not all valid `u32`s are valid `char`s. `from_u32()` will return `None` if the input is not a valid value for a `char`.

For an unsafe version of this function which ignores these checks, see `from_u32_unchecked`.

# Examples

Basic usage:

    use std::char;

    let c = char::from_u32(0x2764);

    assert_eq!(Some('❤'), c);Run

Returning `None` when the input is not a valid `char`:

    use std::char;

    let c = char::from_u32(0x110000);

    assert_eq!(None, c);Run

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
↑
  Move up in search results
↓
  Move down in search results
↹
  Switch tab
⏎
  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`)