diff options
| author | kwantam <kwantam@gmail.com> | 2014-06-30 17:04:10 -0400 |
|---|---|---|
| committer | kwantam <kwantam@gmail.com> | 2014-07-07 14:52:24 -0400 |
| commit | 5d4238b6fc8769c35ff5818ed04d16a6deab784f (patch) | |
| tree | 085ec3efe2b40fabad3603104a2f93f00df6926a /src/libstd | |
| parent | 4f120e6bafe971452adfede158a7957b00562a4e (diff) | |
| download | rust-5d4238b6fc8769c35ff5818ed04d16a6deab784f.tar.gz rust-5d4238b6fc8769c35ff5818ed04d16a6deab784f.zip | |
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 1d339b03af6..52f8a53ad62 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -237,6 +237,7 @@ use str::{Str, StrSlice, StrAllocating}; 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 113b0410875..10db5c1bf9f 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 61e8b63af35..338f6fdffed 100644 --- a/src/libstd/prelude.rs +++ b/src/libstd/prelude.rs @@ -88,6 +88,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; |
