Skip to content

Commit 86a79c9

Browse files
committed
[libstd_unicode] Expose UnicodeVersion type
In <#42998>, we added an uninstantiable type for the internal `UNICODE_VERSION` value, `UnicodeVersion`, but it was not made public to the outside of the crate, resulting in the value becoming less useful. Here we make the type accessible from the outside. Also add a run-pass test to make sure the type and value can be accessed as intended.
1 parent 0701b37 commit 86a79c9

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/libstd_unicode/char.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub use core::char::CharTryFromError;
4747
#[unstable(feature = "decode_utf8", issue = "33906")]
4848
pub use core::char::{DecodeUtf8, decode_utf8};
4949
#[unstable(feature = "unicode", issue = "27783")]
50-
pub use tables::UNICODE_VERSION;
50+
pub use tables::{UnicodeVersion, UNICODE_VERSION};
5151

5252
/// Returns an iterator that yields the lowercase equivalent of a `char`.
5353
///

src/test/run-pass/char_unicode.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
12+
#![feature(unicode)]
13+
14+
15+
/// Tests access to the internal Unicode Version type and value.
16+
pub fn main() {
17+
check(std::char::UNICODE_VERSION);
18+
}
19+
20+
pub fn check(unicode_version: std::char::UnicodeVersion) {
21+
assert!(unicode_version.major >= 10);
22+
}

0 commit comments

Comments
 (0)