about summary refs log tree commit diff
path: root/src/libstd_unicode
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-08-08 06:48:45 +0000
committerbors <bors@rust-lang.org>2017-08-08 06:48:45 +0000
commitd69cdca153ac34259a64189e9f77a5e5afadbcf4 (patch)
tree53abd969a946615566dd44e3dfb03be5692b88d1 /src/libstd_unicode
parent7c4e1a5036db1085d118ab83f76be431695602f6 (diff)
parent42f886110afd8c944c9a94d82d65e17bf704f03f (diff)
downloadrust-d69cdca153ac34259a64189e9f77a5e5afadbcf4.tar.gz
rust-d69cdca153ac34259a64189e9f77a5e5afadbcf4.zip
Auto merge of #42998 - behnam:uni-ver-type, r=sfackler
[libstd_unicode] Change UNICODE_VERSION to use u32

Looks like there's no strong reason to keep these values at `u64`.

With the current plans for the Unicode Standard, `u8` should be enough for the next 200 years. To stay on the safe side, I'm using `u16` here. I don't see a reason to go with anything machine-dependent/more-efficient.
Diffstat (limited to 'src/libstd_unicode')
-rw-r--r--src/libstd_unicode/tables.rs29
-rwxr-xr-xsrc/libstd_unicode/unicode.py29
2 files changed, 52 insertions, 6 deletions
diff --git a/src/libstd_unicode/tables.rs b/src/libstd_unicode/tables.rs
index 0938738b52c..1e8a0be8096 100644
--- a/src/libstd_unicode/tables.rs
+++ b/src/libstd_unicode/tables.rs
@@ -12,9 +12,32 @@
 
 #![allow(missing_docs, non_upper_case_globals, non_snake_case)]
 
-/// The version of [Unicode](http://www.unicode.org/)
-/// that the unicode parts of `CharExt` and `UnicodeStrPrelude` traits are based on.
-pub const UNICODE_VERSION: (u64, u64, u64) = (10, 0, 0);
+/// Represents a Unicode Version.
+///
+/// See also: <http://www.unicode.org/versions/>
+#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
+pub struct UnicodeVersion {
+    /// Major version.
+    pub major: u32,
+
+    /// Minor version.
+    pub minor: u32,
+
+    /// Micro (or Update) version.
+    pub micro: u32,
+
+    // Private field to keep struct expandable.
+    _priv: (),
+}
+
+/// The version of [Unicode](http://www.unicode.org/) that the Unicode parts of
+/// `CharExt` and `UnicodeStrPrelude` traits are based on.
+pub const UNICODE_VERSION: UnicodeVersion = UnicodeVersion {
+    major: 10,
+    minor: 0,
+    micro: 0,
+    _priv: (),
+};
 
 
 // BoolTrie is a trie for representing a set of Unicode codepoints. It is
diff --git a/src/libstd_unicode/unicode.py b/src/libstd_unicode/unicode.py
index 5f9def02c7d..1fac859242e 100755
--- a/src/libstd_unicode/unicode.py
+++ b/src/libstd_unicode/unicode.py
@@ -560,9 +560,32 @@ if __name__ == "__main__":
             pattern = "for Version (\d+)\.(\d+)\.(\d+) of the Unicode"
             unicode_version = re.search(pattern, readme.read()).groups()
         rf.write("""
-/// The version of [Unicode](http://www.unicode.org/)
-/// that the unicode parts of `CharExt` and `UnicodeStrPrelude` traits are based on.
-pub const UNICODE_VERSION: (u64, u64, u64) = (%s, %s, %s);
+/// Represents a Unicode Version.
+///
+/// See also: <http://www.unicode.org/versions/>
+#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
+pub struct UnicodeVersion {
+    /// Major version.
+    pub major: u32,
+
+    /// Minor version.
+    pub minor: u32,
+
+    /// Micro (or Update) version.
+    pub micro: u32,
+
+    // Private field to keep struct expandable.
+    _priv: (),
+}
+
+/// The version of [Unicode](http://www.unicode.org/) that the Unicode parts of
+/// `CharExt` and `UnicodeStrPrelude` traits are based on.
+pub const UNICODE_VERSION: UnicodeVersion = UnicodeVersion {
+    major: %s,
+    minor: %s,
+    micro: %s,
+    _priv: (),
+};
 """ % unicode_version)
         (canon_decomp, compat_decomp, gencats, combines,
                 to_upper, to_lower, to_title) = load_unicode_data("UnicodeData.txt")