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.
This commit is contained in:
parent
1f3b65921e
commit
7f4048c710
@ -37,8 +37,6 @@
|
||||
|
||||
// unstable re-exports
|
||||
#[unstable(feature = "unicode_version", issue = "49726")]
|
||||
pub use crate::unicode::version::UnicodeVersion;
|
||||
#[unstable(feature = "unicode_version", issue = "49726")]
|
||||
pub use crate::unicode::UNICODE_VERSION;
|
||||
|
||||
use crate::fmt::{self, Write};
|
||||
|
@ -3,19 +3,14 @@
|
||||
|
||||
pub(crate) mod printable;
|
||||
mod unicode_data;
|
||||
pub(crate) mod version;
|
||||
|
||||
use version::UnicodeVersion;
|
||||
|
||||
/// The version of [Unicode](http://www.unicode.org/) that the Unicode parts of
|
||||
/// `char` and `str` methods are based on.
|
||||
///
|
||||
/// The version numbering scheme is explained in
|
||||
/// [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).
|
||||
#[unstable(feature = "unicode_version", issue = "49726")]
|
||||
pub const UNICODE_VERSION: UnicodeVersion = UnicodeVersion {
|
||||
major: unicode_data::UNICODE_VERSION.0,
|
||||
minor: unicode_data::UNICODE_VERSION.1,
|
||||
micro: unicode_data::UNICODE_VERSION.2,
|
||||
_priv: (),
|
||||
};
|
||||
pub const UNICODE_VERSION: (u8, u8, u8) = unicode_data::UNICODE_VERSION;
|
||||
|
||||
// For use in liballoc, not re-exported in libstd.
|
||||
pub mod derived_property {
|
||||
|
@ -94,7 +94,7 @@ fn skip_search<const SOR: usize, const OFFSETS: usize>(
|
||||
offset_idx % 2 == 1
|
||||
}
|
||||
|
||||
pub const UNICODE_VERSION: (u32, u32, u32) = (13, 0, 0);
|
||||
pub const UNICODE_VERSION: (u8, u8, u8) = (13, 0, 0);
|
||||
|
||||
#[rustfmt::skip]
|
||||
pub mod alphabetic {
|
||||
|
@ -1,18 +0,0 @@
|
||||
/// Represents a Unicode Version.
|
||||
///
|
||||
/// See also: <http://www.unicode.org/versions/>
|
||||
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
|
||||
#[unstable(feature = "unicode_version", issue = "49726")]
|
||||
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.
|
||||
pub(crate) _priv: (),
|
||||
}
|
@ -7,6 +7,6 @@ pub fn main() {
|
||||
check(std::char::UNICODE_VERSION);
|
||||
}
|
||||
|
||||
pub fn check(unicode_version: std::char::UnicodeVersion) {
|
||||
assert!(unicode_version.major >= 10);
|
||||
pub fn check(unicode_version: (u8, u8, u8)) {
|
||||
assert!(unicode_version.0 >= 10);
|
||||
}
|
||||
|
@ -295,7 +295,7 @@ fn main() {
|
||||
|
||||
fn version() -> String {
|
||||
let mut out = String::new();
|
||||
out.push_str("pub const UNICODE_VERSION: (u32, u32, u32) = ");
|
||||
out.push_str("pub const UNICODE_VERSION: (u8, u8, u8) = ");
|
||||
|
||||
let readme =
|
||||
std::fs::read_to_string(std::path::Path::new(UNICODE_DIRECTORY).join("ReadMe.txt"))
|
||||
|
Loading…
Reference in New Issue
Block a user