diff options
| author | bors <bors@rust-lang.org> | 2014-07-09 18:36:30 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-07-09 18:36:30 +0000 |
| commit | fa7cbb5a46ddc15c6e5c8ad8f49a537a0cd10732 (patch) | |
| tree | b0d5dbc9d6721dc1a17d61348938b3da82e5700e /src/libstd | |
| parent | f9d3b9e488f88b5d9c9e23f9bcc7e933565a9649 (diff) | |
| parent | 85e2bee4a2ca3e63ea47389377b632403db20195 (diff) | |
| download | rust-fa7cbb5a46ddc15c6e5c8ad8f49a537a0cd10732.tar.gz rust-fa7cbb5a46ddc15c6e5c8ad8f49a537a0cd10732.zip | |
auto merge of #15283 : kwantam/rust/master, r=alexcrichton
Add libunicode; move unicode functions from core
- created new crate, libunicode, below libstd
- split `Char` trait into `Char` (libcore) and `UnicodeChar` (libunicode)
- Unicode-aware functions now live in libunicode
- `is_alphabetic`, `is_XID_start`, `is_XID_continue`, `is_lowercase`,
`is_uppercase`, `is_whitespace`, `is_alphanumeric`, `is_control`, `is_digit`,
`to_uppercase`, `to_lowercase`
- added `width` method in UnicodeChar trait
- determines printed width of character in columns, or None if it is a non-NULL control character
- takes a boolean argument indicating whether the present context is CJK or not (characters with 'A'mbiguous widths are double-wide in CJK contexts, single-wide otherwise)
- split `StrSlice` into `StrSlice` (libcore) and `UnicodeStrSlice` (libunicode)
- functionality formerly in `StrSlice` that relied upon Unicode functionality from `Char` is now in `UnicodeStrSlice`
- `words`, `is_whitespace`, `is_alphanumeric`, `trim`, `trim_left`, `trim_right`
- also moved `Words` type alias into libunicode because `words` method is in `UnicodeStrSlice`
- unified Unicode tables from libcollections, libcore, and libregex into libunicode
- updated `unicode.py` in `src/etc` to generate aforementioned tables
- generated new tables based on latest Unicode data
- added `UnicodeChar` and `UnicodeStrSlice` traits to prelude
- libunicode is now the collection point for the `std::char` module, combining the libunicode functionality with the `Char` functionality from libcore
- thus, moved doc comment for `char` from `core::char` to `unicode::char`
- libcollections remains the collection point for `std::str`
The Unicode-aware functions that previously lived in the `Char` and `StrSlice` traits are no longer available to programs that only use libcore. To regain use of these methods, include the libunicode crate and `use` the `UnicodeChar` and/or `UnicodeStrSlice` traits:
extern crate unicode;
use unicode::UnicodeChar;
use unicode::UnicodeStrSlice;
use unicode::Words; // if you want to use the words() method
NOTE: this does *not* impact programs that use libstd, since UnicodeChar and UnicodeStrSlice have been added to the prelude.
closes #15224
[breaking-change]
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/io/mod.rs | 1 | ||||
| -rw-r--r-- | src/libstd/lib.rs | 4 | ||||
| -rw-r--r-- | src/libstd/path/windows.rs | 5 | ||||
| -rw-r--r-- | src/libstd/prelude.rs | 1 | ||||
| -rw-r--r-- | src/libstd/rt/backtrace.rs | 2 |
5 files changed, 9 insertions, 4 deletions
diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index fe9016453f7..4ef2e51fcf0 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -237,6 +237,7 @@ use str::{Str, StrSlice}; use str; use string::String; use uint; +use unicode::UnicodeChar; use vec::Vec; // Reexports diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 928a1088d0e..586f513835b 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -126,6 +126,7 @@ #[cfg(test)] #[phase(plugin, link)] extern crate log; extern crate alloc; +extern crate unicode; extern crate core; extern crate core_collections = "collections"; extern crate core_rand = "rand"; @@ -148,7 +149,6 @@ extern crate rustrt; pub use core::any; pub use core::bool; pub use core::cell; -pub use core::char; pub use core::clone; #[cfg(not(test))] pub use core::cmp; pub use core::default; @@ -180,6 +180,8 @@ pub use core_collections::vec; pub use rustrt::c_str; pub use rustrt::local_data; +pub use unicode::char; + pub use core_sync::comm; // Run tests with libgreen instead of libnative. diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs index 206f75739e8..5e42d740e03 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -24,6 +24,7 @@ use option::{Option, Some, None}; use slice::{Vector, ImmutableVector}; use str::{CharSplits, Str, StrAllocating, StrVector, StrSlice}; use string::String; +use unicode::UnicodeChar; use vec::Vec; use super::{contains_nul, BytesContainer, GenericPath, GenericPathUnsafe}; @@ -997,7 +998,7 @@ fn parse_prefix<'a>(mut path: &'a str) -> Option<PathPrefix> { let idx = path.find('\\'); if idx == Some(2) && path.as_bytes()[1] == ':' as u8 { let c = path.as_bytes()[0]; - if c.is_ascii() && ::char::is_alphabetic(c as char) { + if c.is_ascii() && (c as char).is_alphabetic() { // \\?\C:\ path return Some(VerbatimDiskPrefix); } @@ -1021,7 +1022,7 @@ fn parse_prefix<'a>(mut path: &'a str) -> Option<PathPrefix> { } else if path.len() > 1 && path.as_bytes()[1] == ':' as u8 { // C: let c = path.as_bytes()[0]; - if c.is_ascii() && ::char::is_alphabetic(c as char) { + if c.is_ascii() && (c as char).is_alphabetic() { return Some(DiskPrefix); } } diff --git a/src/libstd/prelude.rs b/src/libstd/prelude.rs index 6d60fc19d5d..83ea33a1e69 100644 --- a/src/libstd/prelude.rs +++ b/src/libstd/prelude.rs @@ -89,6 +89,7 @@ #[doc(no_inline)] pub use slice::{Vector, VectorVector}; #[doc(no_inline)] pub use slice::MutableVectorAllocating; #[doc(no_inline)] pub use string::String; +#[doc(no_inline)] pub use unicode::{UnicodeChar, UnicodeStrSlice}; #[doc(no_inline)] pub use vec::Vec; // Reexported runtime types diff --git a/src/libstd/rt/backtrace.rs b/src/libstd/rt/backtrace.rs index 404887823cb..09922b5ad76 100644 --- a/src/libstd/rt/backtrace.rs +++ b/src/libstd/rt/backtrace.rs @@ -12,7 +12,6 @@ #![allow(non_camel_case_types)] -use char::Char; use collections::Collection; use from_str::from_str; use io::{IoResult, Writer}; @@ -22,6 +21,7 @@ use os; use result::{Ok, Err}; use str::StrSlice; use sync::atomics; +use unicode::UnicodeChar; pub use self::imp::write; |
