diff --git a/apps/cli/Cargo.toml b/apps/cli/Cargo.toml index 2ab47532..dfdf9676 100644 --- a/apps/cli/Cargo.toml +++ b/apps/cli/Cargo.toml @@ -11,8 +11,7 @@ readme = "README.md" [dependencies] -unic-ucd = { path = "../../unic/ucd/", version = "0.6.0" } -unic-char-property = { path = "../../unic/char/property/", version = "0.6.0" } +unic = { path = "../../unic/", version = "0.6.0" } clap = "2.29" lazy_static = "1.0" diff --git a/apps/cli/src/bin/unic-inspector.rs b/apps/cli/src/bin/unic-inspector.rs index 86059916..bdf06ae9 100644 --- a/apps/cli/src/bin/unic-inspector.rs +++ b/apps/cli/src/bin/unic-inspector.rs @@ -10,19 +10,19 @@ #[macro_use] extern crate clap; + #[macro_use] extern crate prettytable; -extern crate unic_char_property; +extern crate unic; extern crate unic_cli; -extern crate unic_ucd; use clap::Arg; use prettytable::format::TableFormat; use prettytable::Table; -use unic_char_property::EnumeratedCharProperty; -use unic_ucd::{GeneralCategory, Name}; +use unic::char::property::EnumeratedCharProperty; +use unic::ucd::{GeneralCategory, Name}; fn main() { let app = app_from_crate!() diff --git a/apps/cli/src/bin/unic-versions.rs b/apps/cli/src/bin/unic-versions.rs new file mode 100644 index 00000000..672d027a --- /dev/null +++ b/apps/cli/src/bin/unic-versions.rs @@ -0,0 +1,94 @@ +// Copyright 2017 The UNIC Project Developers. +// +// See the COPYRIGHT file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![forbid(unsafe_code)] + +//! Command-line tool to list versions of UNIC components. + +extern crate unic; + +macro_rules! print_component_desc { + ( $component:tt ) => ( + println!("Component: {}", unic::$component::PKG_DESCRIPTION); + ); +} + +macro_rules! print_component_name_version { + ( $component:tt ) => ( + println!( + "Package: {} ({})", + unic::$component::PKG_NAME, + unic::$component::PKG_VERSION + ); + ); +} + +macro_rules! print_unicode_version { + ( $component:tt ) => ( + println!( + "Unicode Version: {}.{}.{}", + unic::$component::UNICODE_VERSION.major, + unic::$component::UNICODE_VERSION.minor, + unic::$component::UNICODE_VERSION.micro + ); + ); +} + +macro_rules! print_emoji_version { + ( $component:tt ) => ( + println!( + "Emoji Version: {}.{}.{}", + unic::$component::EMOJI_VERSION.major, + unic::$component::EMOJI_VERSION.minor, + unic::$component::EMOJI_VERSION.micro + ); + ); +} + +macro_rules! print_component_info { + ( $component:tt ) => ( + print_component_desc!($component); + print_component_name_version!($component); + println!(); + ); +} + +macro_rules! print_component_info_with_unicode_version { + ( $component:tt ) => ( + print_component_desc!($component); + print_component_name_version!($component); + print_unicode_version!($component); + println!(); + ); +} + +macro_rules! print_component_info_with_emoji_version { + ( $component:tt ) => ( + print_component_desc!($component); + print_component_name_version!($component); + print_emoji_version!($component); + println!(); + ); +} + +fn main() { + println!("UNIC: Unicode and Internationalization Crates for Rust"); + println!("Package: unic ({})", unic::PKG_VERSION); + println!(); + + print_component_info!(char); + + print_component_info_with_unicode_version!(ucd); + print_component_info_with_unicode_version!(bidi); + print_component_info_with_unicode_version!(normal); + print_component_info_with_unicode_version!(idna); + + print_component_info_with_emoji_version!(emoji); +} diff --git a/etc/check-components.sh b/etc/check-components.sh new file mode 100755 index 00000000..99e90fcb --- /dev/null +++ b/etc/check-components.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +# Copyright 2017 The UNIC Project Developers. +# +# See the COPYRIGHT file at the top-level directory of this distribution. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +# Since `cargo publish --all` does not exist yet, we use this dumb alternative +# solution for now. +# +# Main downside of this approch is that there are separate `target/` +# directories used for each component, increasing the test and publish process +# time. + +set -e + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +. "$DIR/common.sh" + + +# Steps + +# Package all components +for component in $COMPONENTS; do + pkg_file="$component/src/pkg_info.rs" + if [ ! -f "$pkg_file" ] + then + echo "Missing pkg_file: $component" + fi +done diff --git a/etc/common.sh b/etc/common.sh index 8aa9c091..ecdd8d82 100644 --- a/etc/common.sh +++ b/etc/common.sh @@ -15,6 +15,8 @@ set -e # List of components, in order of dependency export COMPONENTS=" + unic/common + unic/char/property unic/char/range unic/char diff --git a/unic/Cargo.toml b/unic/Cargo.toml index aa2d3326..827fe213 100644 --- a/unic/Cargo.toml +++ b/unic/Cargo.toml @@ -14,13 +14,14 @@ exclude = [] [features] default = [] -unstable = [] # Rust nightly features +unstable = ["unic-common/unstable"] # Rust nightly features bench_it = ["unic-bidi/bench_it"] serde = ["unic-bidi/serde"] [dependencies] unic-bidi = { path = "bidi/", version = "0.6.0" } unic-char = { path = "char/", version = "0.6.0", features = ["std"] } +unic-common = { path = "common/", version = "0.6.0" } unic-emoji = { path = "emoji/", version = "0.6.0" } unic-idna = { path = "idna/", version = "0.6.0" } unic-normal = { path = "normal/", version = "0.6.0" } diff --git a/unic/bidi/src/lib.rs b/unic/bidi/src/lib.rs index f36f264e..c2d5167b 100644 --- a/unic/bidi/src/lib.rs +++ b/unic/bidi/src/lib.rs @@ -77,26 +77,23 @@ extern crate serde; #[cfg(all(feature = "serde", test))] extern crate serde_test; +pub use unic_ucd_bidi::UNICODE_VERSION; +pub use unic_ucd_bidi::{bidi_class, BidiClass, BidiClassCategory}; + +mod pkg_info; +pub use pkg_info::{PKG_DESCRIPTION, PKG_NAME, PKG_VERSION}; + pub mod format_chars; + pub mod level; +pub use level::Level; mod bidi_info; -mod explicit; -mod implicit; -mod prepare; - -pub use unic_ucd_bidi::UNICODE_VERSION; -pub use unic_ucd_bidi::{bidi_class, BidiClass, BidiClassCategory}; - pub use bidi_info::{BidiInfo, ParagraphInfo}; -pub use level::Level; -pub use prepare::LevelRun; -/// UNIC component version. -pub const PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); +mod explicit; -/// UNIC component name. -pub const PKG_NAME: &str = env!("CARGO_PKG_NAME"); +mod implicit; -/// UNIC component description. -pub const PKG_DESCRIPTION: &str = env!("CARGO_PKG_DESCRIPTION"); +mod prepare; +pub use prepare::LevelRun; diff --git a/unic/bidi/src/pkg_info.rs b/unic/bidi/src/pkg_info.rs new file mode 100644 index 00000000..a1ab2853 --- /dev/null +++ b/unic/bidi/src/pkg_info.rs @@ -0,0 +1,20 @@ +// Copyright 2017 The UNIC Project Developers. +// +// See the COPYRIGHT file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Package information + +/// UNIC component version. +pub const PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); + +/// UNIC component name. +pub const PKG_NAME: &str = env!("CARGO_PKG_NAME"); + +/// UNIC component description. +pub const PKG_DESCRIPTION: &str = env!("CARGO_PKG_DESCRIPTION"); diff --git a/unic/char/property/src/lib.rs b/unic/char/property/src/lib.rs index 1fb1225b..9d8843ae 100644 --- a/unic/char/property/src/lib.rs +++ b/unic/char/property/src/lib.rs @@ -28,16 +28,14 @@ #[macro_use] extern crate unic_char_range; -// pub because is used in macros, called from macro call-site. -pub mod tables; - -mod macros; mod pkg_info; -mod property; -mod range_types; +pub use pkg_info::{PKG_DESCRIPTION, PKG_NAME, PKG_VERSION}; +mod property; pub use self::property::{CharProperty, PartialCharProperty, TotalCharProperty}; -pub use self::range_types::{ + +mod range_types; +pub use range_types::{ BinaryCharProperty, CustomCharProperty, EnumeratedCharProperty, @@ -45,8 +43,11 @@ pub use self::range_types::{ NumericCharPropertyValue, }; +mod macros; + +// pub because is used in macros, called from macro call-site. +pub mod tables; + // Used in macros #[doc(hidden)] pub use core::{fmt as __fmt, str as __str}; - -pub use pkg_info::{PKG_DESCRIPTION, PKG_NAME, PKG_VERSION}; diff --git a/unic/char/range/src/lib.rs b/unic/char/range/src/lib.rs index ea61d5f6..b4def677 100644 --- a/unic/char/range/src/lib.rs +++ b/unic/char/range/src/lib.rs @@ -52,10 +52,17 @@ #[cfg(feature = "std")] extern crate core; -mod iter; -mod macros; mod pkg_info; +pub use pkg_info::{PKG_DESCRIPTION, PKG_NAME, PKG_VERSION}; + +mod iter; +pub use iter::CharIter; + mod range; +pub use range::CharRange; + +mod macros; + mod step; #[cfg(feature = "fused")] @@ -63,8 +70,3 @@ mod iter_fused; #[cfg(feature = "trusted-len")] mod iter_trusted_len; - -pub use range::CharRange; -pub use iter::CharIter; - -pub use pkg_info::{PKG_DESCRIPTION, PKG_NAME, PKG_VERSION}; diff --git a/unic/char/src/lib.rs b/unic/char/src/lib.rs index 04206f07..c3fb0f40 100644 --- a/unic/char/src/lib.rs +++ b/unic/char/src/lib.rs @@ -19,5 +19,4 @@ pub extern crate unic_char_property as property; pub extern crate unic_char_range as range; mod pkg_info; - pub use pkg_info::{PKG_DESCRIPTION, PKG_NAME, PKG_VERSION}; diff --git a/unic/common/Cargo.toml b/unic/common/Cargo.toml new file mode 100644 index 00000000..25ef61e7 --- /dev/null +++ b/unic/common/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "unic-common" +version = "0.6.0" +authors = ["The UNIC Project Developers"] +repository = "https://github.com/behnam/rust-unic/" +license = "MIT/Apache-2.0" +description = "UNIC - Common Utilities" +keywords = ["unicode", "version"] +categories = ["internationalization", "text-processing"] + +# No tests/benches that depends on /data/ +exclude = [] + +[features] +default = [] +unstable = [] # Rust nightly features + +[badges] +travis-ci = { repository = "behnam/rust-unic", branch = "master" } diff --git a/unic/common/README.md b/unic/common/README.md new file mode 100644 index 00000000..9d86d229 --- /dev/null +++ b/unic/common/README.md @@ -0,0 +1,7 @@ +# UNIC — Common Utilities + +[![Crates.io](https://img.shields.io/crates/v/unic-common.svg)](https://crates.io/crates/unic-common) +[![Documentation](https://docs.rs/unic-common/badge.svg)](https://docs.rs/unic-common/) + +This UNIC component provides common types, algorithms and macros not shared +between many components. diff --git a/unic/common/src/lib.rs b/unic/common/src/lib.rs new file mode 100644 index 00000000..611b6225 --- /dev/null +++ b/unic/common/src/lib.rs @@ -0,0 +1,25 @@ +// Copyright 2017 The UNIC Project Developers. +// +// See the COPYRIGHT file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![no_std] +#![forbid(unsafe_code, missing_docs, unconditional_recursion)] +#![cfg_attr(feature = "unstable", feature(unicode))] + +//! # UNIC — Common Utilities +//! +//! A component of [`unic`: Unicode and Internationalization Crates for Rust](/unic/). +//! +//! This UNIC component provides common types, algorithms and macros not shared between many +//! components. + +mod pkg_info; +pub use pkg_info::{PKG_DESCRIPTION, PKG_NAME, PKG_VERSION}; + +pub mod version; diff --git a/unic/common/src/pkg_info.rs b/unic/common/src/pkg_info.rs new file mode 100644 index 00000000..a1ab2853 --- /dev/null +++ b/unic/common/src/pkg_info.rs @@ -0,0 +1,20 @@ +// Copyright 2017 The UNIC Project Developers. +// +// See the COPYRIGHT file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Package information + +/// UNIC component version. +pub const PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); + +/// UNIC component name. +pub const PKG_NAME: &str = env!("CARGO_PKG_NAME"); + +/// UNIC component description. +pub const PKG_DESCRIPTION: &str = env!("CARGO_PKG_DESCRIPTION"); diff --git a/unic/common/src/version.rs b/unic/common/src/version.rs new file mode 100644 index 00000000..4fe5cedc --- /dev/null +++ b/unic/common/src/version.rs @@ -0,0 +1,78 @@ +// Copyright 2017 The UNIC Project Developers. +// +// See the COPYRIGHT file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! *Version* data types. + +use core::fmt; + +/* TODO(behnam) +#[cfg(feature = "unstable")] +use core::char; +*/ + +/// Represents a *Unicode Version* type. +/// +/// UNIC's *Unicode Version* type is used for Unicode datasets and specifications, including The +/// Unicode Standard (TUS), Unicode Character Database (UCD), Common Local Data Repository (CLDR), +/// IDNA, Emoji, etc. +/// +/// TODO: *Unicode Version* is guaranteed to have three integer fields between 0 and 255. We are +/// going to switch over to `u8` after Unicode 11.0.0 release. +/// +/// Refs: +/// - +/// - +#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Debug, Hash, Default)] +pub struct UnicodeVersion { + /// Major version. + pub major: u16, + + /// Minor version. + pub minor: u16, + + /// Micro (or Update) version. + pub micro: u16, +} + +impl fmt::Display for UnicodeVersion { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}.{}.{}", self.major, self.minor, self.micro) + } +} + +/* TODO(behnam): Fails with "ambiguous associated type" +#[cfg(feature = "unstable")] +/// Convert from Rust's internal Unicode Version. +impl From for UnicodeVersion { + fn from(value: char::UnicodeVersion) -> UnicodeVersion { + UnicodeVersion { + major: value.major as u16, + minor: value.minor as u16, + micro: value.micro as u16, + } + } +} +*/ + +#[cfg(test)] +mod tests { + /* TODO(behnam) + #[cfg(feature = "unstable")] + #[test] + fn test_against_rust_internal() { + use core::char; + + use super::UnicodeVersion; + + let core: UnicodeVersion = char::UNICODE_VERSION.into(); + assert!(core.major >= 10); + } + */ +} diff --git a/unic/emoji/char/src/lib.rs b/unic/emoji/char/src/lib.rs index 091f9306..e8cfcbbf 100644 --- a/unic/emoji/char/src/lib.rs +++ b/unic/emoji/char/src/lib.rs @@ -22,21 +22,22 @@ extern crate unic_char_range; extern crate unic_ucd_version; mod pkg_info; - -mod emoji_version; - -mod emoji; -mod emoji_component; -mod emoji_modifier; -mod emoji_modifier_base; -mod emoji_presentation; - pub use pkg_info::{PKG_DESCRIPTION, PKG_NAME, PKG_VERSION}; +mod emoji_version; pub use emoji_version::{UnicodeVersion, EMOJI_VERSION}; +mod emoji; pub use emoji::{is_emoji, Emoji}; + +mod emoji_component; pub use emoji_component::{is_emoji_component, EmojiComponent}; + +mod emoji_modifier; pub use emoji_modifier::{is_emoji_modifier, EmojiModifier}; + +mod emoji_modifier_base; pub use emoji_modifier_base::{is_emoji_modifier_base, EmojiModifierBase}; + +mod emoji_presentation; pub use emoji_presentation::{is_emoji_presentation, EmojiPresentation}; diff --git a/unic/emoji/src/lib.rs b/unic/emoji/src/lib.rs index 0d0342ad..650e4b81 100644 --- a/unic/emoji/src/lib.rs +++ b/unic/emoji/src/lib.rs @@ -20,5 +20,6 @@ pub extern crate unic_emoji_char as char; mod pkg_info; - pub use pkg_info::{PKG_DESCRIPTION, PKG_NAME, PKG_VERSION}; + +pub use char::EMOJI_VERSION; diff --git a/unic/idna/mapping/src/lib.rs b/unic/idna/mapping/src/lib.rs index 10c98299..e601b232 100644 --- a/unic/idna/mapping/src/lib.rs +++ b/unic/idna/mapping/src/lib.rs @@ -26,16 +26,10 @@ mod mapping; use unic_ucd_version::UnicodeVersion; +mod pkg_info; +pub use pkg_info::{PKG_DESCRIPTION, PKG_NAME, PKG_VERSION}; + pub use mapping::Mapping; /// The version of [Unicode IDNA Compatibility Processing](https://www.unicode.org/reports/tr46/) pub const UNICODE_VERSION: UnicodeVersion = include!("../tables/unicode_version.rsv"); - -/// UNIC component version. -pub const PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); - -/// UNIC component name. -pub const PKG_NAME: &str = env!("CARGO_PKG_NAME"); - -/// UNIC component description. -pub const PKG_DESCRIPTION: &str = env!("CARGO_PKG_DESCRIPTION"); diff --git a/unic/idna/mapping/src/pkg_info.rs b/unic/idna/mapping/src/pkg_info.rs new file mode 100644 index 00000000..a1ab2853 --- /dev/null +++ b/unic/idna/mapping/src/pkg_info.rs @@ -0,0 +1,20 @@ +// Copyright 2017 The UNIC Project Developers. +// +// See the COPYRIGHT file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Package information + +/// UNIC component version. +pub const PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); + +/// UNIC component name. +pub const PKG_NAME: &str = env!("CARGO_PKG_NAME"); + +/// UNIC component description. +pub const PKG_DESCRIPTION: &str = env!("CARGO_PKG_DESCRIPTION"); diff --git a/unic/idna/punycode/src/lib.rs b/unic/idna/punycode/src/lib.rs index f9f3ebba..31b2f617 100644 --- a/unic/idna/punycode/src/lib.rs +++ b/unic/idna/punycode/src/lib.rs @@ -25,10 +25,14 @@ use std::u32; use std::char; + // TODO: Drop following after MIN_RUST_VERSION >= 1.23 #[allow(unused_imports)] use std::ascii::AsciiExt; +mod pkg_info; +pub use pkg_info::{PKG_DESCRIPTION, PKG_NAME, PKG_VERSION}; + // Bootstring parameters for Punycode static BASE: u32 = 36; static T_MIN: u32 = 1; diff --git a/unic/idna/punycode/src/pkg_info.rs b/unic/idna/punycode/src/pkg_info.rs new file mode 100644 index 00000000..a1ab2853 --- /dev/null +++ b/unic/idna/punycode/src/pkg_info.rs @@ -0,0 +1,20 @@ +// Copyright 2017 The UNIC Project Developers. +// +// See the COPYRIGHT file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Package information + +/// UNIC component version. +pub const PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); + +/// UNIC component name. +pub const PKG_NAME: &str = env!("CARGO_PKG_NAME"); + +/// UNIC component description. +pub const PKG_DESCRIPTION: &str = env!("CARGO_PKG_DESCRIPTION"); diff --git a/unic/idna/src/lib.rs b/unic/idna/src/lib.rs index 6b74e6a7..747bbd90 100644 --- a/unic/idna/src/lib.rs +++ b/unic/idna/src/lib.rs @@ -48,18 +48,12 @@ extern crate unic_ucd_normal; extern crate unic_idna_mapping as mapping; extern crate unic_idna_punycode as punycode; -mod process; +mod pkg_info; +pub use pkg_info::{PKG_DESCRIPTION, PKG_NAME, PKG_VERSION}; pub use mapping::UNICODE_VERSION; + +mod process; pub use process::PUNYCODE_PREFIX; pub use process::{Errors, Flags}; pub use process::{to_ascii, to_unicode}; - -/// UNIC component version. -pub const PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); - -/// UNIC component name. -pub const PKG_NAME: &str = env!("CARGO_PKG_NAME"); - -/// UNIC component description. -pub const PKG_DESCRIPTION: &str = env!("CARGO_PKG_DESCRIPTION"); diff --git a/unic/idna/src/pkg_info.rs b/unic/idna/src/pkg_info.rs new file mode 100644 index 00000000..a1ab2853 --- /dev/null +++ b/unic/idna/src/pkg_info.rs @@ -0,0 +1,20 @@ +// Copyright 2017 The UNIC Project Developers. +// +// See the COPYRIGHT file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Package information + +/// UNIC component version. +pub const PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); + +/// UNIC component name. +pub const PKG_NAME: &str = env!("CARGO_PKG_NAME"); + +/// UNIC component description. +pub const PKG_DESCRIPTION: &str = env!("CARGO_PKG_DESCRIPTION"); diff --git a/unic/normal/src/lib.rs b/unic/normal/src/lib.rs index 3ce8afda..dac4cd5e 100644 --- a/unic/normal/src/lib.rs +++ b/unic/normal/src/lib.rs @@ -41,14 +41,8 @@ pub use unic_ucd_normal::UNICODE_VERSION; pub use decompose::Decompositions; pub use recompose::Recompositions; -/// UNIC component version. -pub const PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); - -/// UNIC component name. -pub const PKG_NAME: &str = env!("CARGO_PKG_NAME"); - -/// UNIC component description. -pub const PKG_DESCRIPTION: &str = env!("CARGO_PKG_DESCRIPTION"); +mod pkg_info; +pub use pkg_info::{PKG_DESCRIPTION, PKG_NAME, PKG_VERSION}; /// Methods for iterating over strings while applying Unicode normalizations /// as described in diff --git a/unic/normal/src/pkg_info.rs b/unic/normal/src/pkg_info.rs new file mode 100644 index 00000000..a1ab2853 --- /dev/null +++ b/unic/normal/src/pkg_info.rs @@ -0,0 +1,20 @@ +// Copyright 2017 The UNIC Project Developers. +// +// See the COPYRIGHT file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Package information + +/// UNIC component version. +pub const PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); + +/// UNIC component name. +pub const PKG_NAME: &str = env!("CARGO_PKG_NAME"); + +/// UNIC component description. +pub const PKG_DESCRIPTION: &str = env!("CARGO_PKG_DESCRIPTION"); diff --git a/unic/segment/src/lib.rs b/unic/segment/src/lib.rs index f6c5ba01..398c7280 100644 --- a/unic/segment/src/lib.rs +++ b/unic/segment/src/lib.rs @@ -77,19 +77,13 @@ extern crate unic_ucd_segment; #[cfg(test)] extern crate unic_ucd_common; -mod grapheme; -mod word; - pub use unic_ucd_segment::UNICODE_VERSION; -pub use grapheme::{GraphemeCursor, GraphemeIncomplete, GraphemeIndices, Graphemes}; -pub use word::{WordBoundIndices, WordBounds, Words}; - -/// UNIC component version. -pub const PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); +mod pkg_info; +pub use pkg_info::{PKG_DESCRIPTION, PKG_NAME, PKG_VERSION}; -/// UNIC component name. -pub const PKG_NAME: &str = env!("CARGO_PKG_NAME"); +mod grapheme; +pub use grapheme::{GraphemeCursor, GraphemeIncomplete, GraphemeIndices, Graphemes}; -/// UNIC component description. -pub const PKG_DESCRIPTION: &str = env!("CARGO_PKG_DESCRIPTION"); +mod word; +pub use word::{WordBoundIndices, WordBounds, Words}; diff --git a/unic/segment/src/pkg_info.rs b/unic/segment/src/pkg_info.rs new file mode 100644 index 00000000..a1ab2853 --- /dev/null +++ b/unic/segment/src/pkg_info.rs @@ -0,0 +1,20 @@ +// Copyright 2017 The UNIC Project Developers. +// +// See the COPYRIGHT file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Package information + +/// UNIC component version. +pub const PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); + +/// UNIC component name. +pub const PKG_NAME: &str = env!("CARGO_PKG_NAME"); + +/// UNIC component description. +pub const PKG_DESCRIPTION: &str = env!("CARGO_PKG_DESCRIPTION"); diff --git a/unic/src/bin/unic-versions.rs b/unic/src/bin/unic-versions.rs deleted file mode 100644 index 6d383971..00000000 --- a/unic/src/bin/unic-versions.rs +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2017 The UNIC Project Developers. -// -// See the COPYRIGHT file at the top-level directory of this distribution. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![forbid(unsafe_code)] - -//! Command-line tool to list versions of UNIC components. - -extern crate unic; - -const PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); - -macro_rules! print_pkg_name_desc_version { - ( $component:tt ) => { - println!("Component: {}", unic::$component::PKG_DESCRIPTION); - println!( - "Package: {}:{}", - unic::$component::PKG_NAME, - unic::$component::PKG_VERSION, - ); - } -} - -macro_rules! print_unicode_version { - ( $component:tt ) => { - println!( - "Unicode Version: {}.{}.{}", - unic::$component::UNICODE_VERSION.major, - unic::$component::UNICODE_VERSION.minor, - unic::$component::UNICODE_VERSION.micro, - ); - } -} - -fn main() { - println!("UNIC: Unicode and Internationalization Crates for Rust"); - println!("Package: unic:{}", PKG_VERSION); - println!(); - - print_pkg_name_desc_version!(char); - println!(); - - print_pkg_name_desc_version!(ucd); - print_unicode_version!(ucd); - println!(); - - print_pkg_name_desc_version!(bidi); - print_unicode_version!(bidi); - println!(); - - print_pkg_name_desc_version!(normal); - print_unicode_version!(normal); - println!(); - - print_pkg_name_desc_version!(idna); - print_unicode_version!(idna); - println!(); - - /* FIXME(behnam) - print_pkg_name_desc_version!(emoji); - print_unicode_version!(emoji); - println!(); - */ -} diff --git a/unic/src/lib.rs b/unic/src/lib.rs index bb67abe0..1d8058e4 100644 --- a/unic/src/lib.rs +++ b/unic/src/lib.rs @@ -175,3 +175,6 @@ pub extern crate unic_ucd as ucd; /// The [Unicode version](https://www.unicode.org/versions/) of data pub use ucd::UNICODE_VERSION; + +mod pkg_info; +pub use pkg_info::{PKG_DESCRIPTION, PKG_NAME, PKG_VERSION}; diff --git a/unic/src/pkg_info.rs b/unic/src/pkg_info.rs new file mode 100644 index 00000000..a1ab2853 --- /dev/null +++ b/unic/src/pkg_info.rs @@ -0,0 +1,20 @@ +// Copyright 2017 The UNIC Project Developers. +// +// See the COPYRIGHT file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Package information + +/// UNIC component version. +pub const PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); + +/// UNIC component name. +pub const PKG_NAME: &str = env!("CARGO_PKG_NAME"); + +/// UNIC component description. +pub const PKG_DESCRIPTION: &str = env!("CARGO_PKG_DESCRIPTION"); diff --git a/unic/ucd/age/src/lib.rs b/unic/ucd/age/src/lib.rs index 9b8749b4..fcf2883e 100644 --- a/unic/ucd/age/src/lib.rs +++ b/unic/ucd/age/src/lib.rs @@ -26,10 +26,12 @@ extern crate unic_char_property; extern crate unic_char_range; extern crate unic_ucd_version; -mod age; - pub use unic_ucd_version::UnicodeVersion; +mod pkg_info; +pub use pkg_info::{PKG_DESCRIPTION, PKG_NAME, PKG_VERSION}; + +mod age; pub use age::{Age, CharAge}; /// The [Unicode version](https://www.unicode.org/versions/) of data diff --git a/unic/ucd/age/src/pkg_info.rs b/unic/ucd/age/src/pkg_info.rs new file mode 100644 index 00000000..a1ab2853 --- /dev/null +++ b/unic/ucd/age/src/pkg_info.rs @@ -0,0 +1,20 @@ +// Copyright 2017 The UNIC Project Developers. +// +// See the COPYRIGHT file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Package information + +/// UNIC component version. +pub const PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); + +/// UNIC component name. +pub const PKG_NAME: &str = env!("CARGO_PKG_NAME"); + +/// UNIC component description. +pub const PKG_DESCRIPTION: &str = env!("CARGO_PKG_DESCRIPTION"); diff --git a/unic/ucd/bidi/src/lib.rs b/unic/ucd/bidi/src/lib.rs index 66758ed3..2b03f583 100644 --- a/unic/ucd/bidi/src/lib.rs +++ b/unic/ucd/bidi/src/lib.rs @@ -27,12 +27,16 @@ extern crate unic_char_range; extern crate unic_ucd_version; -pub mod bidi_class; -pub mod bidi_control; -pub mod bidi_mirrored; +mod pkg_info; +pub use pkg_info::{PKG_DESCRIPTION, PKG_NAME, PKG_VERSION}; +pub mod bidi_class; pub use bidi_class::{BidiClass, BidiClassCategory, CharBidiClass, StrBidiClass}; + +pub mod bidi_control; pub use bidi_control::{is_bidi_control, BidiControl}; + +pub mod bidi_mirrored; pub use bidi_mirrored::{is_bidi_mirrored, BidiMirrored}; use unic_ucd_version::UnicodeVersion; diff --git a/unic/ucd/bidi/src/pkg_info.rs b/unic/ucd/bidi/src/pkg_info.rs new file mode 100644 index 00000000..a1ab2853 --- /dev/null +++ b/unic/ucd/bidi/src/pkg_info.rs @@ -0,0 +1,20 @@ +// Copyright 2017 The UNIC Project Developers. +// +// See the COPYRIGHT file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Package information + +/// UNIC component version. +pub const PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); + +/// UNIC component name. +pub const PKG_NAME: &str = env!("CARGO_PKG_NAME"); + +/// UNIC component description. +pub const PKG_DESCRIPTION: &str = env!("CARGO_PKG_DESCRIPTION"); diff --git a/unic/ucd/case/src/lib.rs b/unic/ucd/case/src/lib.rs index f0da62ba..039c09c0 100644 --- a/unic/ucd/case/src/lib.rs +++ b/unic/ucd/case/src/lib.rs @@ -26,25 +26,34 @@ extern crate unic_char_range; extern crate unic_ucd_version; -pub mod lowercase; -pub mod uppercase; -pub mod cased; -pub mod case_ignorable; -pub mod changes_when_lowercased; -pub mod changes_when_uppercased; -pub mod changes_when_titlecased; -pub mod changes_when_casefolded; -pub mod changes_when_casemapped; +mod pkg_info; +pub use pkg_info::{PKG_DESCRIPTION, PKG_NAME, PKG_VERSION}; +pub mod lowercase; pub use lowercase::{is_lowercase, Lowercase}; + +pub mod uppercase; pub use uppercase::{is_uppercase, Uppercase}; + +pub mod cased; pub use cased::{is_cased, Cased}; + +pub mod case_ignorable; pub use case_ignorable::{is_case_ignorable, CaseIgnorable}; +pub mod changes_when_lowercased; pub use changes_when_lowercased::{changes_when_lowercased, ChangesWhenLowercased}; + +pub mod changes_when_uppercased; pub use changes_when_uppercased::{changes_when_uppercased, ChangesWhenUppercased}; + +pub mod changes_when_titlecased; pub use changes_when_titlecased::{changes_when_titlecased, ChangesWhenTitlecased}; + +pub mod changes_when_casefolded; pub use changes_when_casefolded::{changes_when_casefolded, ChangesWhenCasefolded}; + +pub mod changes_when_casemapped; pub use changes_when_casemapped::{changes_when_casemapped, ChangesWhenCasemapped}; use unic_ucd_version::UnicodeVersion; diff --git a/unic/ucd/case/src/pkg_info.rs b/unic/ucd/case/src/pkg_info.rs new file mode 100644 index 00000000..a1ab2853 --- /dev/null +++ b/unic/ucd/case/src/pkg_info.rs @@ -0,0 +1,20 @@ +// Copyright 2017 The UNIC Project Developers. +// +// See the COPYRIGHT file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Package information + +/// UNIC component version. +pub const PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); + +/// UNIC component name. +pub const PKG_NAME: &str = env!("CARGO_PKG_NAME"); + +/// UNIC component description. +pub const PKG_DESCRIPTION: &str = env!("CARGO_PKG_DESCRIPTION"); diff --git a/unic/ucd/category/src/lib.rs b/unic/ucd/category/src/lib.rs index 1bd758b8..2856765c 100644 --- a/unic/ucd/category/src/lib.rs +++ b/unic/ucd/category/src/lib.rs @@ -46,8 +46,10 @@ extern crate unic_char_property; extern crate unic_char_range; extern crate unic_ucd_version; -mod category; +mod pkg_info; +pub use pkg_info::{PKG_DESCRIPTION, PKG_NAME, PKG_VERSION}; +mod category; pub use category::GeneralCategory; use unic_ucd_version::UnicodeVersion; diff --git a/unic/ucd/category/src/pkg_info.rs b/unic/ucd/category/src/pkg_info.rs new file mode 100644 index 00000000..a1ab2853 --- /dev/null +++ b/unic/ucd/category/src/pkg_info.rs @@ -0,0 +1,20 @@ +// Copyright 2017 The UNIC Project Developers. +// +// See the COPYRIGHT file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Package information + +/// UNIC component version. +pub const PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); + +/// UNIC component name. +pub const PKG_NAME: &str = env!("CARGO_PKG_NAME"); + +/// UNIC component description. +pub const PKG_DESCRIPTION: &str = env!("CARGO_PKG_DESCRIPTION"); diff --git a/unic/ucd/common/src/lib.rs b/unic/ucd/common/src/lib.rs index 37e5db05..3be4872b 100644 --- a/unic/ucd/common/src/lib.rs +++ b/unic/ucd/common/src/lib.rs @@ -25,19 +25,26 @@ extern crate unic_char_range; extern crate unic_ucd_version; -pub mod alphabetic; -pub mod alphanumeric; -pub mod control; -pub mod numeric; -pub mod white_space; +mod pkg_info; +pub use pkg_info::{PKG_DESCRIPTION, PKG_NAME, PKG_VERSION}; + +// == UCD-defined: types and methods == -// UCD-defined: types and methods +pub mod alphabetic; pub use alphabetic::{is_alphabetic, Alphabetic}; + +pub mod white_space; pub use white_space::{is_white_space, WhiteSpace}; -// Non-UCD-defined: methods only +// == Non-UCD-defined: methods only == + +pub mod alphanumeric; pub use alphanumeric::is_alphanumeric; + +pub mod control; pub use control::is_control; + +pub mod numeric; pub use numeric::is_numeric; use unic_ucd_version::UnicodeVersion; diff --git a/unic/ucd/common/src/pkg_info.rs b/unic/ucd/common/src/pkg_info.rs new file mode 100644 index 00000000..a1ab2853 --- /dev/null +++ b/unic/ucd/common/src/pkg_info.rs @@ -0,0 +1,20 @@ +// Copyright 2017 The UNIC Project Developers. +// +// See the COPYRIGHT file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Package information + +/// UNIC component version. +pub const PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); + +/// UNIC component name. +pub const PKG_NAME: &str = env!("CARGO_PKG_NAME"); + +/// UNIC component description. +pub const PKG_DESCRIPTION: &str = env!("CARGO_PKG_DESCRIPTION"); diff --git a/unic/ucd/ident/src/lib.rs b/unic/ucd/ident/src/lib.rs index ba2b0004..38e81479 100644 --- a/unic/ucd/ident/src/lib.rs +++ b/unic/ucd/ident/src/lib.rs @@ -33,6 +33,9 @@ extern crate unic_char_property; extern crate unic_char_range; extern crate unic_ucd_version; +mod pkg_info; +pub use pkg_info::{PKG_DESCRIPTION, PKG_NAME, PKG_VERSION}; + #[cfg(feature = "xid")] mod xid { char_property! { diff --git a/unic/ucd/ident/src/pkg_info.rs b/unic/ucd/ident/src/pkg_info.rs new file mode 100644 index 00000000..a1ab2853 --- /dev/null +++ b/unic/ucd/ident/src/pkg_info.rs @@ -0,0 +1,20 @@ +// Copyright 2017 The UNIC Project Developers. +// +// See the COPYRIGHT file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Package information + +/// UNIC component version. +pub const PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); + +/// UNIC component name. +pub const PKG_NAME: &str = env!("CARGO_PKG_NAME"); + +/// UNIC component description. +pub const PKG_DESCRIPTION: &str = env!("CARGO_PKG_DESCRIPTION"); diff --git a/unic/ucd/name/src/lib.rs b/unic/ucd/name/src/lib.rs index 2e0e905a..733482e4 100644 --- a/unic/ucd/name/src/lib.rs +++ b/unic/ucd/name/src/lib.rs @@ -13,10 +13,13 @@ extern crate unic_char_property; extern crate unic_ucd_version; +mod pkg_info; +pub use pkg_info::{PKG_DESCRIPTION, PKG_NAME, PKG_VERSION}; + mod name; +pub use name::Name; use unic_ucd_version::UnicodeVersion; -pub use name::Name; - +/// The [Unicode version](https://www.unicode.org/versions/) of data pub const UNICODE_VERSION: UnicodeVersion = include!("../tables/unicode_version.rsv"); diff --git a/unic/ucd/name/src/pkg_info.rs b/unic/ucd/name/src/pkg_info.rs new file mode 100644 index 00000000..a1ab2853 --- /dev/null +++ b/unic/ucd/name/src/pkg_info.rs @@ -0,0 +1,20 @@ +// Copyright 2017 The UNIC Project Developers. +// +// See the COPYRIGHT file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Package information + +/// UNIC component version. +pub const PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); + +/// UNIC component name. +pub const PKG_NAME: &str = env!("CARGO_PKG_NAME"); + +/// UNIC component description. +pub const PKG_DESCRIPTION: &str = env!("CARGO_PKG_DESCRIPTION"); diff --git a/unic/ucd/normal/src/lib.rs b/unic/ucd/normal/src/lib.rs index dc5a57d1..dd908abe 100644 --- a/unic/ucd/normal/src/lib.rs +++ b/unic/ucd/normal/src/lib.rs @@ -34,23 +34,25 @@ extern crate unic_char_property; extern crate unic_char_range; extern crate unic_ucd_version; +mod pkg_info; +pub use pkg_info::{PKG_DESCRIPTION, PKG_NAME, PKG_VERSION}; + pub mod canonical_combining_class; +pub use canonical_combining_class::CanonicalCombiningClass; + mod composition; +pub use composition::{canonical_composition, canonical_decomposition, compatibility_decomposition}; + mod decomposition; -mod gen_cat; -mod hangul; -mod decomposition_type; +pub use decomposition::{decompose_canonical, decompose_compatible}; -pub use canonical_combining_class::CanonicalCombiningClass; -pub use composition::{canonical_composition, canonical_decomposition, compatibility_decomposition}; +mod gen_cat; pub use gen_cat::is_combining_mark; -pub use decomposition::{decompose_canonical, decompose_compatible}; -pub use decomposition_type::DecompositionType; -use unic_ucd_version::UnicodeVersion; +mod decomposition_type; +pub use decomposition_type::DecompositionType; -/// The [Unicode version](https://www.unicode.org/versions/) of data -pub const UNICODE_VERSION: UnicodeVersion = include!("../tables/unicode_version.rsv"); +mod hangul; /// Compose two characters into a single character, if possible. /// See [Unicode Standard Annex #15](https://www.unicode.org/reports/tr15/) @@ -58,3 +60,8 @@ pub const UNICODE_VERSION: UnicodeVersion = include!("../tables/unicode_version. pub fn compose(a: char, b: char) -> Option { hangul::compose(a, b).or_else(|| canonical_composition(a).and_then(|table| table.find(b))) } + +use unic_ucd_version::UnicodeVersion; + +/// The [Unicode version](https://www.unicode.org/versions/) of data +pub const UNICODE_VERSION: UnicodeVersion = include!("../tables/unicode_version.rsv"); diff --git a/unic/ucd/normal/src/pkg_info.rs b/unic/ucd/normal/src/pkg_info.rs new file mode 100644 index 00000000..a1ab2853 --- /dev/null +++ b/unic/ucd/normal/src/pkg_info.rs @@ -0,0 +1,20 @@ +// Copyright 2017 The UNIC Project Developers. +// +// See the COPYRIGHT file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Package information + +/// UNIC component version. +pub const PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); + +/// UNIC component name. +pub const PKG_NAME: &str = env!("CARGO_PKG_NAME"); + +/// UNIC component description. +pub const PKG_DESCRIPTION: &str = env!("CARGO_PKG_DESCRIPTION"); diff --git a/unic/ucd/segment/src/lib.rs b/unic/ucd/segment/src/lib.rs index 1ef7e7d2..8f0ef959 100644 --- a/unic/ucd/segment/src/lib.rs +++ b/unic/ucd/segment/src/lib.rs @@ -26,12 +26,16 @@ extern crate unic_char_range; extern crate unic_ucd_version; -pub mod grapheme_cluster_break; -pub mod sentence_break; -pub mod word_break; +mod pkg_info; +pub use pkg_info::{PKG_DESCRIPTION, PKG_NAME, PKG_VERSION}; +pub mod grapheme_cluster_break; pub use grapheme_cluster_break::GraphemeClusterBreak; + +pub mod sentence_break; pub use sentence_break::SentenceBreak; + +pub mod word_break; pub use word_break::WordBreak; use unic_ucd_version::UnicodeVersion; diff --git a/unic/ucd/segment/src/pkg_info.rs b/unic/ucd/segment/src/pkg_info.rs new file mode 100644 index 00000000..a1ab2853 --- /dev/null +++ b/unic/ucd/segment/src/pkg_info.rs @@ -0,0 +1,20 @@ +// Copyright 2017 The UNIC Project Developers. +// +// See the COPYRIGHT file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Package information + +/// UNIC component version. +pub const PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); + +/// UNIC component name. +pub const PKG_NAME: &str = env!("CARGO_PKG_NAME"); + +/// UNIC component description. +pub const PKG_DESCRIPTION: &str = env!("CARGO_PKG_DESCRIPTION"); diff --git a/unic/ucd/src/lib.rs b/unic/ucd/src/lib.rs index 49d340cc..4bec8f5c 100644 --- a/unic/ucd/src/lib.rs +++ b/unic/ucd/src/lib.rs @@ -23,25 +23,17 @@ pub extern crate unic_ucd_bidi as bidi; pub extern crate unic_ucd_case as case; pub extern crate unic_ucd_category as category; pub extern crate unic_ucd_common as common; +pub extern crate unic_ucd_ident as ident; pub extern crate unic_ucd_name as name; pub extern crate unic_ucd_normal as normal; pub extern crate unic_ucd_segment as segment; pub extern crate unic_ucd_version as version; +pub use version::UnicodeVersion; + /// The [Unicode version](https://www.unicode.org/versions/) of data pub use version::UNICODE_VERSION; -/// UNIC component version. -pub const PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); - -/// UNIC component name. -pub const PKG_NAME: &str = env!("CARGO_PKG_NAME"); - -/// UNIC component description. -pub const PKG_DESCRIPTION: &str = env!("CARGO_PKG_DESCRIPTION"); - -pub use version::UnicodeVersion; - pub use age::{Age, CharAge}; pub use bidi::{is_bidi_mirrored, BidiClass, CharBidiClass, StrBidiClass}; @@ -76,3 +68,6 @@ pub use name::Name; pub use normal::CanonicalCombiningClass; pub use segment::{GraphemeClusterBreak, SentenceBreak, WordBreak}; + +mod pkg_info; +pub use pkg_info::{PKG_DESCRIPTION, PKG_NAME, PKG_VERSION}; diff --git a/unic/ucd/src/pkg_info.rs b/unic/ucd/src/pkg_info.rs new file mode 100644 index 00000000..a1ab2853 --- /dev/null +++ b/unic/ucd/src/pkg_info.rs @@ -0,0 +1,20 @@ +// Copyright 2017 The UNIC Project Developers. +// +// See the COPYRIGHT file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Package information + +/// UNIC component version. +pub const PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); + +/// UNIC component name. +pub const PKG_NAME: &str = env!("CARGO_PKG_NAME"); + +/// UNIC component description. +pub const PKG_DESCRIPTION: &str = env!("CARGO_PKG_DESCRIPTION"); diff --git a/unic/ucd/version/Cargo.toml b/unic/ucd/version/Cargo.toml index 392ee2be..6c310a36 100644 --- a/unic/ucd/version/Cargo.toml +++ b/unic/ucd/version/Cargo.toml @@ -13,3 +13,6 @@ exclude = [] [badges] travis-ci = { repository = "behnam/rust-unic", branch = "master" } + +[dependencies] +unic-common = { path = "../../common/", version = "0.6.0" } diff --git a/unic/ucd/version/src/lib.rs b/unic/ucd/version/src/lib.rs index 250e8bd8..0d52e804 100644 --- a/unic/ucd/version/src/lib.rs +++ b/unic/ucd/version/src/lib.rs @@ -17,9 +17,12 @@ //! //! Core create indicating the version of Unicode Character Database. -mod pkg_info; -mod unicode_version; +extern crate unic_common; + +pub use unic_common::version::UnicodeVersion; +mod pkg_info; pub use pkg_info::{PKG_DESCRIPTION, PKG_NAME, PKG_VERSION}; -pub use unicode_version::{UnicodeVersion, UNICODE_VERSION}; +mod unicode_version; +pub use unicode_version::UNICODE_VERSION; diff --git a/unic/ucd/version/src/unicode_version.rs b/unic/ucd/version/src/unicode_version.rs index a3965ed7..8e96e7f0 100644 --- a/unic/ucd/version/src/unicode_version.rs +++ b/unic/ucd/version/src/unicode_version.rs @@ -8,50 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![cfg_attr(feature = "unstable", feature(unicode))] - -use core::fmt; - -#[cfg(feature = "unstable")] -use core::char; - -/// Represents a *Unicode Version*, as used for Unicode datasets and specifications. -/// -/// TODO: *Unicode Version* is guaranteed to have three integer fields between 0 and 255. We are -/// going to switch over to `u8` after Unicode 11.0.0 release. -/// -/// Refs: -/// - -/// - -#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Debug, Hash, Default)] -pub struct UnicodeVersion { - /// Major version. - pub major: u16, - - /// Minor version. - pub minor: u16, - - /// Micro (or Update) version. - pub micro: u16, -} - -impl fmt::Display for UnicodeVersion { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}.{}.{}", self.major, self.minor, self.micro) - } -} - -#[cfg(feature = "unstable")] -/// Convert from Rust's internal Unicode Version. -impl From for UnicodeVersion { - fn from(value: char::UnicodeVersion) -> UnicodeVersion { - UnicodeVersion { - major: value.major.into(), - minor: value.minor.into(), - micro: value.micro.into(), - } - } -} +use unic_common::version::UnicodeVersion; /// The [Version of The Unicode Standard](https://www.unicode.org/versions/) of the Unicode /// Character Database in use. @@ -59,9 +16,6 @@ pub const UNICODE_VERSION: UnicodeVersion = include!("../tables/unicode_version. #[cfg(test)] mod tests { - #[cfg(feature = "unstable")] - use core::char; - use super::UNICODE_VERSION; #[test] @@ -72,13 +26,4 @@ mod tests { // no Minor updates. We hard-code this internal policy while it stands. assert!(UNICODE_VERSION.minor == 0); } - - #[cfg(feature = "unstable")] - #[test] - fn test_against_rust_internal_unicore_version() { - use super::UnicodeVersion; - let core_uni_ver: UnicodeVersion = char::UnicodeVersion.into(); - assert!(core_uni_ver.major >= 10); - assert!(UNICODE_VERSION.major >= core_uni_ver.major); - } }