diff options
| author | Brian Anderson <banderson@mozilla.com> | 2014-10-08 17:03:04 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2014-11-21 12:49:51 -0800 |
| commit | 41fb8f77ee10221db319096ee45a56a29f013564 (patch) | |
| tree | d49f49b21b51cafdcd53218b3362f0d5d9b45328 | |
| parent | f530aa08dfcdaeb249341bdd1a9797780b4294c2 (diff) | |
core: Add from_u32 to the Char trait
This is the only free function not part of the trait.
| -rw-r--r-- | src/libcore/char.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libcore/char.rs b/src/libcore/char.rs index e4dc9ce5bd4..db58f802643 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<Self>; + /// Converts from `u32` to a `char` + fn from_u32(i: u32) -> Option<char>; + /// 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<char> { from_digit(num, radix) } + #[inline] + fn from_u32(i: u32) -> Option<char> { from_u32(i) } + fn escape_unicode(&self, f: |char|) { escape_unicode(*self, f) } fn escape_default(&self, f: |char|) { escape_default(*self, f) } |
