Skip to content

Commit 41fb8f7

Browse files
committed
core: Add from_u32 to the Char trait
This is the only free function not part of the trait.
1 parent f530aa0 commit 41fb8f7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/libcore/char.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,9 @@ pub trait Char {
270270
/// Panics if given a radix > 36.
271271
fn from_digit(num: uint, radix: uint) -> Option<Self>;
272272

273+
/// Converts from `u32` to a `char`
274+
fn from_u32(i: u32) -> Option<char>;
275+
273276
/// Returns the hexadecimal Unicode escape of a character.
274277
///
275278
/// The rules are as follows:
@@ -319,6 +322,9 @@ impl Char for char {
319322

320323
fn from_digit(num: uint, radix: uint) -> Option<char> { from_digit(num, radix) }
321324

325+
#[inline]
326+
fn from_u32(i: u32) -> Option<char> { from_u32(i) }
327+
322328
fn escape_unicode(&self, f: |char|) { escape_unicode(*self, f) }
323329

324330
fn escape_default(&self, f: |char|) { escape_default(*self, f) }

0 commit comments

Comments
 (0)