Debian Codegraph @

src/version.rs

raw symbols SCIP
1 // Copyright 2017 The UNIC Project Developers.
2 //
3 // See the COPYRIGHT file at the top-level directory of this distribution.
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 //! *Version* data types.
12
13 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/;
14
15 #[cfg(feature = "unstable")]
16 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::charrust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/;
17
18 /// Represents a *Unicode Version* type.
19 ///
20 /// UNIC's *Unicode Version* type is used for Unicode datasets and specifications, including The
21 /// Unicode Standard (TUS), Unicode Character Database (UCD), Common Local Data Repository (CLDR),
22 /// IDNA, Emoji, etc.
23 ///
24 /// TODO: *Unicode Version* is guaranteed to have three integer fields between 0 and 255. We are
25 /// going to switch over to `u8` after Unicode 11.0.0 release.
26 ///
27 /// Refs:
28 /// - <https://www.unicode.org/versions/>
29 /// - <https://www.unicode.org/L2/L2017/17222.htm#152-C3>
30 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:)]
31 pub struct UnicodeVersionrust-analyzer cargo unic-common 0.9.0 version/UnicodeVersion# {
32 /// Major version.
33 pub majorrust-analyzer cargo unic-common 0.9.0 version/UnicodeVersion#major.: u16,
34
35 /// Minor version.
36 pub minorrust-analyzer cargo unic-common 0.9.0 version/UnicodeVersion#minor.: u16,
37
38 /// Micro (or Update) version.
39 pub microrust-analyzer cargo unic-common 0.9.0 version/UnicodeVersion#micro.: u16,
40 }
41
42 impl fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for UnicodeVersionrust-analyzer cargo unic-common 0.9.0 version/UnicodeVersion# {
43 fn fmtrust-analyzer cargo unic-common 0.9.0 version/impl#[UnicodeVersion][Display]fmt().(&self, f: &mut fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
44 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "{}.{}.{}", self.majorrust-analyzer cargo unic-common 0.9.0 version/UnicodeVersion#major., self.minorrust-analyzer cargo unic-common 0.9.0 version/UnicodeVersion#minor., self.microrust-analyzer cargo unic-common 0.9.0 version/UnicodeVersion#micro.)
45 }
46 }
47
48 #[cfg(feature = "unstable")]
49 /// Convert from Rust's internal Unicode Version.
50 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<char::UnicodeVersion> for UnicodeVersionrust-analyzer cargo unic-common 0.9.0 version/UnicodeVersion# {
51 fn fromrust-analyzer cargo unic-common 0.9.0 version/impl#[UnicodeVersion][`From<_>`]from().(value: char::UnicodeVersion) -> UnicodeVersionrust-analyzer cargo unic-common 0.9.0 version/UnicodeVersion# {
52 UnicodeVersionrust-analyzer cargo unic-common 0.9.0 version/UnicodeVersion# {
53 majorrust-analyzer cargo unic-common 0.9.0 version/UnicodeVersion#major.: value.major as u16,
54 minorrust-analyzer cargo unic-common 0.9.0 version/UnicodeVersion#minor.: value.minor as u16,
55 microrust-analyzer cargo unic-common 0.9.0 version/UnicodeVersion#micro.: value.micro as u16,
56 }
57 }
58 }
59
60 #[cfg(test)]
61 mod testsrust-analyzer cargo unic-common 0.9.0 version/tests/ {
62 #[cfg(feature = "unstable")]
63 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
64 fn test_against_rust_internalrust-analyzer cargo unic-common 0.9.0 version/tests/test_against_rust_internal().() {
65 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::charrust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/;
66
67 use superrust-analyzer cargo unic-common 0.9.0 version/::UnicodeVersionrust-analyzer cargo unic-common 0.9.0 version/UnicodeVersion#;
68
69 let core_unicode_version: UnicodeVersionrust-analyzer cargo unic-common 0.9.0 version/UnicodeVersion# = charrust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/::UNICODE_VERSIONrust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/UNICODE_VERSION..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().();
70 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(core_unicode_version.majorrust-analyzer cargo unic-common 0.9.0 version/UnicodeVersion#major. >= 10);
71 }
72 }