Skip to content

Commit b794cb2

Browse files
authored
Rollup merge of #71020 - pyfisch:unicode-version, r=sfackler
Store UNICODE_VERSION as a tuple Remove the UnicodeVersion struct containing major, minor and update fields and replace it with a 3-tuple containing the version number. As the value of each field is limited to 255 use u8 to store them.
2 parents 03a724b + 7f4048c commit b794cb2

File tree

6 files changed

+8
-33
lines changed

6 files changed

+8
-33
lines changed

src/libcore/char/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ pub use self::decode::{decode_utf16, DecodeUtf16, DecodeUtf16Error};
3737

3838
// unstable re-exports
3939
#[unstable(feature = "unicode_version", issue = "49726")]
40-
pub use crate::unicode::version::UnicodeVersion;
41-
#[unstable(feature = "unicode_version", issue = "49726")]
4240
pub use crate::unicode::UNICODE_VERSION;
4341

4442
use crate::fmt::{self, Write};

src/libcore/unicode/mod.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,14 @@
33

44
pub(crate) mod printable;
55
mod unicode_data;
6-
pub(crate) mod version;
7-
8-
use version::UnicodeVersion;
96

107
/// The version of [Unicode](http://www.unicode.org/) that the Unicode parts of
118
/// `char` and `str` methods are based on.
9+
///
10+
/// The version numbering scheme is explained in
11+
/// [Unicode 11.0 or later, Section 3.1 Versions of the Unicode Standard](https://www.unicode.org/versions/Unicode11.0.0/ch03.pdf#page=4).
1212
#[unstable(feature = "unicode_version", issue = "49726")]
13-
pub const UNICODE_VERSION: UnicodeVersion = UnicodeVersion {
14-
major: unicode_data::UNICODE_VERSION.0,
15-
minor: unicode_data::UNICODE_VERSION.1,
16-
micro: unicode_data::UNICODE_VERSION.2,
17-
_priv: (),
18-
};
13+
pub const UNICODE_VERSION: (u8, u8, u8) = unicode_data::UNICODE_VERSION;
1914

2015
// For use in liballoc, not re-exported in libstd.
2116
pub mod derived_property {

src/libcore/unicode/unicode_data.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ fn skip_search<const SOR: usize, const OFFSETS: usize>(
9494
offset_idx % 2 == 1
9595
}
9696

97-
pub const UNICODE_VERSION: (u32, u32, u32) = (13, 0, 0);
97+
pub const UNICODE_VERSION: (u8, u8, u8) = (13, 0, 0);
9898

9999
#[rustfmt::skip]
100100
pub mod alphabetic {

src/libcore/unicode/version.rs

-18
This file was deleted.

src/test/ui/char_unicode.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ pub fn main() {
77
check(std::char::UNICODE_VERSION);
88
}
99

10-
pub fn check(unicode_version: std::char::UnicodeVersion) {
11-
assert!(unicode_version.major >= 10);
10+
pub fn check(unicode_version: (u8, u8, u8)) {
11+
assert!(unicode_version.0 >= 10);
1212
}

src/tools/unicode-table-generator/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ fn main() {
295295

296296
fn version() -> String {
297297
let mut out = String::new();
298-
out.push_str("pub const UNICODE_VERSION: (u32, u32, u32) = ");
298+
out.push_str("pub const UNICODE_VERSION: (u8, u8, u8) = ");
299299

300300
let readme =
301301
std::fs::read_to_string(std::path::Path::new(UNICODE_DIRECTORY).join("ReadMe.txt"))

0 commit comments

Comments
 (0)