/// Converts from `u32` to a `char`
#[inline]
-#[unstable = "pending decisions about costructors for primitives"]
+#[stable]
pub fn from_u32(i: u32) -> Option<char> {
// catch out-of-bounds and surrogates
if (i > MAX as u32) || (i >= 0xD800 && i <= 0xDFFF) {
/// Panics if given an `radix` > 36.
///
#[inline]
-#[unstable = "pending decisions about costructors for primitives"]
+#[unstable = "pending integer conventions"]
pub fn from_digit(num: uint, radix: uint) -> Option<char> {
if radix > 36 {
panic!("from_digit: radix is too high (maximum 36)");
}
/// Basic `char` manipulations.
-#[experimental = "trait organization may change"]
+#[stable]
pub trait Char {
/// Checks if a `char` parses as a numeric digit in the given radix.
///
/// # Panics
///
/// Panics if given a radix > 36.
- #[unstable = "pending error conventions"]
+ #[unstable = "pending integer conventions"]
fn is_digit(self, radix: uint) -> bool;
/// Converts a character to the corresponding digit.
/// # Panics
///
/// Panics if given a radix outside the range [0..36].
- #[unstable = "pending error conventions, trait organization"]
+ #[unstable = "pending integer conventions"]
fn to_digit(self, radix: uint) -> Option<uint>;
/// Returns an iterator that yields the hexadecimal Unicode escape
/// All characters are escaped with Rust syntax of the form `\\u{NNNN}`
/// where `NNNN` is the shortest hexadecimal representation of the code
/// point.
- #[unstable = "pending error conventions, trait organization"]
+ #[stable]
fn escape_unicode(self) -> EscapeUnicode;
/// Returns an iterator that yields the 'default' ASCII and
/// escaped.
/// * Any other chars in the range [0x20,0x7e] are not escaped.
/// * Any other chars are given hex Unicode escapes; see `escape_unicode`.
- #[unstable = "pending error conventions, trait organization"]
+ #[stable]
fn escape_default(self) -> EscapeDefault;
/// Returns the amount of bytes this character would need if encoded in
/// UTF-8.
- #[unstable = "pending trait organization"]
+ #[stable]
fn len_utf8(self) -> uint;
/// Returns the amount of bytes this character would need if encoded in
/// UTF-16.
- #[unstable = "pending trait organization"]
+ #[stable]
fn len_utf16(self) -> uint;
/// Encodes this character as UTF-8 into the provided byte buffer,
///
/// If the buffer is not large enough, nothing will be written into it
/// and a `None` will be returned.
- #[unstable = "pending trait organization"]
+ #[stable]
fn encode_utf8(self, dst: &mut [u8]) -> Option<uint>;
/// Encodes this character as UTF-16 into the provided `u16` buffer,
///
/// If the buffer is not large enough, nothing will be written into it
/// and a `None` will be returned.
- #[unstable = "pending trait organization"]
+ #[stable]
fn encode_utf16(self, dst: &mut [u16]) -> Option<uint>;
}
-#[experimental = "trait is experimental"]
-impl Char for char {
- #[unstable = "pending trait organization"]
+#[stable]
+impl CharExt for char {
+ #[unstable = "pending integer conventions"]
fn is_digit(self, radix: uint) -> bool {
match self.to_digit(radix) {
Some(_) => true,
}
}
- #[unstable = "pending trait organization"]
+ #[unstable = "pending integer conventions"]
fn to_digit(self, radix: uint) -> Option<uint> {
if radix > 36 {
panic!("to_digit: radix is too high (maximum 36)");
else { None }
}
- #[unstable = "pending error conventions, trait organization"]
+ #[stable]
fn escape_unicode(self) -> EscapeUnicode {
EscapeUnicode { c: self, state: EscapeUnicodeState::Backslash }
}
- #[unstable = "pending error conventions, trait organization"]
+ #[stable]
fn escape_default(self) -> EscapeDefault {
let init_state = match self {
'\t' => EscapeDefaultState::Backslash('t'),
}
#[inline]
- #[unstable = "pending trait organization"]
+ #[stable]
fn len_utf8(self) -> uint {
let code = self as u32;
match () {
}
#[inline]
- #[unstable = "pending trait organization"]
+ #[stable]
fn len_utf16(self) -> uint {
let ch = self as u32;
if (ch & 0xFFFF_u32) == ch { 1 } else { 2 }
}
#[inline]
- #[unstable = "pending error conventions, trait organization"]
+ #[unstable = "pending decision about Iterator/Writer/Reader"]
fn encode_utf8(self, dst: &mut [u8]) -> Option<uint> {
// Marked #[inline] to allow llvm optimizing it away
let code = self as u32;
}
#[inline]
- #[unstable = "pending error conventions, trait organization"]
+ #[unstable = "pending decision about Iterator/Writer/Reader"]
fn encode_utf16(self, dst: &mut [u16]) -> Option<uint> {
// Marked #[inline] to allow llvm optimizing it away
let mut ch = self as u32;
/// An iterator over the characters that represent a `char`, as escaped by
/// Rust's unicode escaping rules.
#[derive(Clone)]
+#[stable]
pub struct EscapeUnicode {
c: char,
state: EscapeUnicodeState
Done,
}
+#[stable]
impl Iterator for EscapeUnicode {
type Item = char;
/// An iterator over the characters that represent a `char`, escaped
/// for maximum portability.
#[derive(Clone)]
+#[stable]
pub struct EscapeDefault {
state: EscapeDefaultState
}
Unicode(EscapeUnicode),
}
+#[stable]
impl Iterator for EscapeDefault {
type Item = char;