From 41fb8f77ee10221db319096ee45a56a29f013564 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 8 Oct 2014 17:03:04 -0700 Subject: [PATCH] core: Add from_u32 to the Char trait This is the only free function not part of the trait. --- src/libcore/char.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libcore/char.rs b/src/libcore/char.rs index e4dc9ce5bd46..db58f802643b 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -270,6 +270,9 @@ pub trait Char { /// Panics if given a radix > 36. fn from_digit(num: uint, radix: uint) -> Option; + /// Converts from `u32` to a `char` + fn from_u32(i: u32) -> Option; + /// Returns the hexadecimal Unicode escape of a character. /// /// The rules are as follows: @@ -319,6 +322,9 @@ impl Char for char { fn from_digit(num: uint, radix: uint) -> Option { from_digit(num, radix) } + #[inline] + fn from_u32(i: u32) -> Option { from_u32(i) } + fn escape_unicode(&self, f: |char|) { escape_unicode(*self, f) } fn escape_default(&self, f: |char|) { escape_default(*self, f) }