Skip to content

Commit 5d4238b

Browse files
committed
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]
1 parent 4f120e6 commit 5d4238b

File tree

25 files changed

+7433
-11587
lines changed

25 files changed

+7433
-11587
lines changed

mk/crates.mk

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,19 @@
5151

5252
TARGET_CRATES := libc std green rustuv native flate arena glob term semver \
5353
uuid serialize sync getopts collections num test time rand \
54-
url log regex graphviz core rlibc alloc debug rustrt
54+
url log regex graphviz core rlibc alloc debug rustrt \
55+
unicode
5556
HOST_CRATES := syntax rustc rustdoc fourcc hexfloat regex_macros fmt_macros
5657
CRATES := $(TARGET_CRATES) $(HOST_CRATES)
5758
TOOLS := compiletest rustdoc rustc
5859

5960
DEPS_core :=
6061
DEPS_rlibc :=
62+
DEPS_unicode := core
6163
DEPS_alloc := core libc native:jemalloc
6264
DEPS_debug := std
6365
DEPS_rustrt := alloc core libc collections native:rustrt_native
64-
DEPS_std := core libc rand alloc collections rustrt sync \
66+
DEPS_std := core libc rand alloc collections rustrt sync unicode \
6567
native:rust_builtin native:backtrace
6668
DEPS_graphviz := std
6769
DEPS_green := std native:context_switch
@@ -82,7 +84,7 @@ DEPS_semver := std
8284
DEPS_uuid := std serialize
8385
DEPS_sync := core alloc rustrt collections
8486
DEPS_getopts := std
85-
DEPS_collections := core alloc
87+
DEPS_collections := core alloc unicode
8688
DEPS_fourcc := rustc syntax std
8789
DEPS_hexfloat := rustc syntax std
8890
DEPS_num := std
@@ -108,6 +110,7 @@ ONLY_RLIB_rlibc := 1
108110
ONLY_RLIB_alloc := 1
109111
ONLY_RLIB_rand := 1
110112
ONLY_RLIB_collections := 1
113+
ONLY_RLIB_unicode := 1
111114

112115
################################################################################
113116
# You should not need to edit below this line

src/etc/regex-unicode-tables.py

Lines changed: 0 additions & 183 deletions
This file was deleted.

0 commit comments

Comments
 (0)