Apply explicit stabilities to unicode parts of CharExt.
This commit is contained in:
parent
0302d37977
commit
e670fb484b
@ -19,7 +19,7 @@ use core::option::Option;
|
||||
use tables::{derived_property, property, general_category, conversions, charwidth};
|
||||
|
||||
/// Functionality for manipulating `char`.
|
||||
#[experimental = "pending prelude organization"]
|
||||
#[stable]
|
||||
pub trait CharExt {
|
||||
/// Checks if a `char` parses as a numeric digit in the given radix.
|
||||
///
|
||||
@ -103,6 +103,7 @@ pub trait CharExt {
|
||||
|
||||
/// Returns whether the specified character is considered a Unicode
|
||||
/// alphabetic code point.
|
||||
#[stable]
|
||||
fn is_alphabetic(self) -> bool;
|
||||
|
||||
/// Returns whether the specified character satisfies the 'XID_Start'
|
||||
@ -111,6 +112,7 @@ pub trait CharExt {
|
||||
/// 'XID_Start' is a Unicode Derived Property specified in
|
||||
/// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications),
|
||||
/// mostly similar to ID_Start but modified for closure under NFKx.
|
||||
#[experimental = "mainly needed for compiler internals"]
|
||||
fn is_xid_start(self) -> bool;
|
||||
|
||||
/// Returns whether the specified `char` satisfies the 'XID_Continue'
|
||||
@ -119,38 +121,45 @@ pub trait CharExt {
|
||||
/// 'XID_Continue' is a Unicode Derived Property specified in
|
||||
/// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications),
|
||||
/// mostly similar to 'ID_Continue' but modified for closure under NFKx.
|
||||
#[experimental = "mainly needed for compiler internals"]
|
||||
fn is_xid_continue(self) -> bool;
|
||||
|
||||
/// Indicates whether a character is in lowercase.
|
||||
///
|
||||
/// This is defined according to the terms of the Unicode Derived Core
|
||||
/// Property `Lowercase`.
|
||||
#[stable]
|
||||
fn is_lowercase(self) -> bool;
|
||||
|
||||
/// Indicates whether a character is in uppercase.
|
||||
///
|
||||
/// This is defined according to the terms of the Unicode Derived Core
|
||||
/// Property `Uppercase`.
|
||||
#[stable]
|
||||
fn is_uppercase(self) -> bool;
|
||||
|
||||
/// Indicates whether a character is whitespace.
|
||||
///
|
||||
/// Whitespace is defined in terms of the Unicode Property `White_Space`.
|
||||
#[stable]
|
||||
fn is_whitespace(self) -> bool;
|
||||
|
||||
/// Indicates whether a character is alphanumeric.
|
||||
///
|
||||
/// Alphanumericness is defined in terms of the Unicode General Categories
|
||||
/// 'Nd', 'Nl', 'No' and the Derived Core Property 'Alphabetic'.
|
||||
#[stable]
|
||||
fn is_alphanumeric(self) -> bool;
|
||||
|
||||
/// Indicates whether a character is a control code point.
|
||||
///
|
||||
/// Control code points are defined in terms of the Unicode General
|
||||
/// Category `Cc`.
|
||||
#[stable]
|
||||
fn is_control(self) -> bool;
|
||||
|
||||
/// Indicates whether the character is numeric (Nd, Nl, or No).
|
||||
#[stable]
|
||||
fn is_numeric(self) -> bool;
|
||||
|
||||
/// Converts a character to its lowercase equivalent.
|
||||
@ -162,6 +171,7 @@ pub trait CharExt {
|
||||
///
|
||||
/// Returns the lowercase equivalent of the character, or the character
|
||||
/// itself if no conversion is possible.
|
||||
#[experimental = "pending case transformation decisions"]
|
||||
fn to_lowercase(self) -> char;
|
||||
|
||||
/// Converts a character to its uppercase equivalent.
|
||||
@ -184,6 +194,7 @@ pub trait CharExt {
|
||||
/// [`SpecialCasing`.txt`]: ftp://ftp.unicode.org/Public/UNIDATA/SpecialCasing.txt
|
||||
///
|
||||
/// [2]: http://www.unicode.org/versions/Unicode4.0.0/ch03.pdf#G33992
|
||||
#[experimental = "pending case transformation decisions"]
|
||||
fn to_uppercase(self) -> char;
|
||||
|
||||
/// Returns this character's displayed width in columns, or `None` if it is a
|
||||
@ -199,7 +210,7 @@ pub trait CharExt {
|
||||
fn width(self, is_cjk: bool) -> Option<uint>;
|
||||
}
|
||||
|
||||
#[experimental = "pending prelude organization"]
|
||||
#[stable]
|
||||
impl CharExt for char {
|
||||
#[unstable = "pending integer conventions"]
|
||||
fn is_digit(self, radix: uint) -> bool { C::is_digit(self, radix) }
|
||||
@ -218,6 +229,7 @@ impl CharExt for char {
|
||||
#[unstable = "pending decision about Iterator/Writer/Reader"]
|
||||
fn encode_utf16(self, dst: &mut [u16]) -> Option<uint> { C::encode_utf16(self, dst) }
|
||||
|
||||
#[stable]
|
||||
fn is_alphabetic(self) -> bool {
|
||||
match self {
|
||||
'a' ... 'z' | 'A' ... 'Z' => true,
|
||||
@ -226,10 +238,13 @@ impl CharExt for char {
|
||||
}
|
||||
}
|
||||
|
||||
#[experimental = "mainly needed for compiler internals"]
|
||||
fn is_xid_start(self) -> bool { derived_property::XID_Start(self) }
|
||||
|
||||
#[experimental = "mainly needed for compiler internals"]
|
||||
fn is_xid_continue(self) -> bool { derived_property::XID_Continue(self) }
|
||||
|
||||
#[stable]
|
||||
fn is_lowercase(self) -> bool {
|
||||
match self {
|
||||
'a' ... 'z' => true,
|
||||
@ -238,6 +253,7 @@ impl CharExt for char {
|
||||
}
|
||||
}
|
||||
|
||||
#[stable]
|
||||
fn is_uppercase(self) -> bool {
|
||||
match self {
|
||||
'A' ... 'Z' => true,
|
||||
@ -246,6 +262,7 @@ impl CharExt for char {
|
||||
}
|
||||
}
|
||||
|
||||
#[stable]
|
||||
fn is_whitespace(self) -> bool {
|
||||
match self {
|
||||
' ' | '\x09' ... '\x0d' => true,
|
||||
@ -254,12 +271,15 @@ impl CharExt for char {
|
||||
}
|
||||
}
|
||||
|
||||
#[stable]
|
||||
fn is_alphanumeric(self) -> bool {
|
||||
self.is_alphabetic() || self.is_numeric()
|
||||
}
|
||||
|
||||
#[stable]
|
||||
fn is_control(self) -> bool { general_category::Cc(self) }
|
||||
|
||||
#[stable]
|
||||
fn is_numeric(self) -> bool {
|
||||
match self {
|
||||
'0' ... '9' => true,
|
||||
@ -268,8 +288,10 @@ impl CharExt for char {
|
||||
}
|
||||
}
|
||||
|
||||
#[experimental = "pending case transformation decisions"]
|
||||
fn to_lowercase(self) -> char { conversions::to_lower(self) }
|
||||
|
||||
#[experimental = "pending case transformation decisions"]
|
||||
fn to_uppercase(self) -> char { conversions::to_upper(self) }
|
||||
|
||||
#[experimental = "needs expert opinion. is_cjk flag stands out as ugly"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user