diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 18:31:36 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 18:31:36 +0000 |
commit | e02c5b5930c2c9ba3e5423fe12e2ef0155017297 (patch) | |
tree | fd60ebbbb5299e16e5fca8c773ddb74f764760db /vendor/unic-char-property | |
parent | Adding debian version 1.73.0+dfsg1-1. (diff) | |
download | rustc-e02c5b5930c2c9ba3e5423fe12e2ef0155017297.tar.xz rustc-e02c5b5930c2c9ba3e5423fe12e2ef0155017297.zip |
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/unic-char-property')
-rw-r--r-- | vendor/unic-char-property/.cargo-checksum.json | 1 | ||||
-rw-r--r-- | vendor/unic-char-property/Cargo.toml | 42 | ||||
-rw-r--r-- | vendor/unic-char-property/src/lib.rs | 59 | ||||
-rw-r--r-- | vendor/unic-char-property/src/macros.rs | 293 | ||||
-rw-r--r-- | vendor/unic-char-property/src/pkg_info.rs | 20 | ||||
-rw-r--r-- | vendor/unic-char-property/src/property.rs | 48 | ||||
-rw-r--r-- | vendor/unic-char-property/src/range_types.rs | 104 | ||||
-rw-r--r-- | vendor/unic-char-property/src/tables.rs | 117 | ||||
-rw-r--r-- | vendor/unic-char-property/tests/bool_property_macro.rs | 73 | ||||
-rw-r--r-- | vendor/unic-char-property/tests/enum_property_macro.rs | 87 | ||||
-rw-r--r-- | vendor/unic-char-property/tests/tables/property_table.rsv | 3 | ||||
-rw-r--r-- | vendor/unic-char-property/tests/tables_tests.rs | 43 |
12 files changed, 0 insertions, 890 deletions
diff --git a/vendor/unic-char-property/.cargo-checksum.json b/vendor/unic-char-property/.cargo-checksum.json deleted file mode 100644 index b10f55705..000000000 --- a/vendor/unic-char-property/.cargo-checksum.json +++ /dev/null @@ -1 +0,0 @@ -{"files":{"Cargo.toml":"1c21185c9bd84959d197f681719106c1a5f4dface3db421b6660bb9801787929","src/lib.rs":"200af9360e201caaa404fea0c8ec5387fa3ead07f8c056adf56d869768b0201b","src/macros.rs":"969bde9782647b7b8acd8fea1721372eb41e747a6a11de0b7dd8ac9b286759f2","src/pkg_info.rs":"37cbe4efd0b0205d251e1ef7714b23e3be27052c8a0de6b1ae3cbf3aefae1fe5","src/property.rs":"f0e34e995306fef0d2a11bac0f7c385d936f6c7d68aed2ec3e33fc7f5eea57ee","src/range_types.rs":"269d781d752c90c0d8d24a299c4d6318ce5d47d843120f019a53df036030def9","src/tables.rs":"1f2a0213d78fc55a6421df8c74b490b9fd60f37a0b882aacccc6838af14b5279","tests/bool_property_macro.rs":"ce18763a5f7eb86925b0fbad1129dd770c9ddefbab76c1ea27d0a437acb20514","tests/enum_property_macro.rs":"3d19cbdfc9f174dbbba696f791f10659af0d1bc5676969e7f84f269faed174f8","tests/tables/property_table.rsv":"efa2f4a8b3a564a35c9412d095920d5aebad515e11a4a1a415f5ef9d1259974c","tests/tables_tests.rs":"94c4e5f1fcf6b7914deb9295c7e7b3840a5310718e5ea875ae3bc01c7349e0da"},"package":"a8c57a407d9b6fa02b4795eb81c5b6652060a15a7903ea981f3d723e6c0be221"}
\ No newline at end of file diff --git a/vendor/unic-char-property/Cargo.toml b/vendor/unic-char-property/Cargo.toml deleted file mode 100644 index 293737450..000000000 --- a/vendor/unic-char-property/Cargo.toml +++ /dev/null @@ -1,42 +0,0 @@ -# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO -# -# When uploading crates to the registry Cargo will automatically -# "normalize" Cargo.toml files for maximal compatibility -# with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g. crates.io) dependencies -# -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) - -[package] -edition = "2018" -name = "unic-char-property" -version = "0.9.0" -authors = ["The UNIC Project Developers"] -exclude = [] -description = "UNIC — Unicode Character Tools — Character Property taxonomy, contracts and build macros" -keywords = ["text", "unicode", "character-property"] -categories = ["internationalization", "text-processing", "parsing"] -license = "MIT/Apache-2.0" -repository = "https://github.com/open-i18n/rust-unic/" -[dependencies.unic-char-range] -version = "0.9.0" -[badges.appveyor] -branch = "master" -repository = "open-i18n/rust-unic" -service = "github" - -[badges.is-it-maintained-issue-resolution] -repository = "open-i18n/rust-unic" - -[badges.is-it-maintained-open-issues] -repository = "open-i18n/rust-unic" - -[badges.maintenance] -status = "actively-developed" - -[badges.travis-ci] -branch = "master" -repository = "open-i18n/rust-unic" diff --git a/vendor/unic-char-property/src/lib.rs b/vendor/unic-char-property/src/lib.rs deleted file mode 100644 index 360a67165..000000000 --- a/vendor/unic-char-property/src/lib.rs +++ /dev/null @@ -1,59 +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 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![no_std] -#![warn( - bad_style, - missing_debug_implementations, - missing_docs, - unconditional_recursion -)] -#![forbid(unsafe_code)] - -//! # UNIC — Unicode Character Tools — Character Property -//! -//! A component of [`unic`: Unicode and Internationalization Crates for Rust](/unic/). -//! -//! Character Property taxonomy, contracts and build macros. -//! -//! ## References -//! -//! * [Unicode UTR #23: The Unicode Character Property Model](http://unicode.org/reports/tr23/). -//! -//! * [Unicode UAX #44: Unicode Character Database](http://unicode.org/reports/tr44/). -//! -//! * [PropertyAliases.txt](https://www.unicode.org/Public/UCD/latest/ucd/PropertyAliases.txt). - -#[macro_use] -extern crate unic_char_range; - -mod pkg_info; -pub use crate::pkg_info::{PKG_DESCRIPTION, PKG_NAME, PKG_VERSION}; - -mod property; -pub use self::property::{CharProperty, PartialCharProperty, TotalCharProperty}; - -mod range_types; -pub use crate::range_types::{ - BinaryCharProperty, - CustomCharProperty, - EnumeratedCharProperty, - NumericCharProperty, - 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}; diff --git a/vendor/unic-char-property/src/macros.rs b/vendor/unic-char-property/src/macros.rs deleted file mode 100644 index b5f054347..000000000 --- a/vendor/unic-char-property/src/macros.rs +++ /dev/null @@ -1,293 +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 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -/// Macro for declaring a character property. -/// -/// # Syntax (Enumerated Property) -/// -/// ``` -/// #[macro_use] -/// extern crate unic_char_property; -/// -/// // First we define the type itself. -/// char_property! { -/// /// This is the enum type created for the character property. -/// pub enum MyProp { -/// abbr => "AbbrPropName"; -/// long => "Long_Property_Name"; -/// human => "Human-Readable Property Name"; -/// -/// /// Zero or more documentation or other attributes. -/// RustName { -/// abbr => AbbrName, -/// long => Long_Name, -/// human => "&'static str that is a nicer presentation of the name", -/// } -/// } -/// -/// /// Module aliasing property value abbreviated names. -/// pub mod abbr_names for abbr; -/// -/// /// Module aliasing property value long names. -/// pub mod long_names for long; -/// } -/// -/// // We also need to impl `PartialCharProperty` or `TotalCharProperty` manually. -/// # impl unic_char_property::PartialCharProperty for MyProp { -/// # fn of(_: char) -> Option<Self> { None } -/// # } -/// # -/// # fn main() {} -/// ``` -/// -/// # Syntax (Binary Property) -/// -/// ``` -/// #[macro_use] extern crate unic_char_property; -/// # #[macro_use] extern crate unic_char_range; -/// -/// char_property! { -/// /// This is the newtype used for the character property. -/// pub struct MyProp(bool) { -/// abbr => "AbbrPropName"; -/// long => "Long_Property_Name"; -/// human => "Human-Readable Property Name"; -/// -/// // Unlike an enumerated property, a binary property will handle the table for you. -/// data_table_path => "../tests/tables/property_table.rsv"; -/// } -/// -/// /// A function that returns whether the given character has the property or not. -/// pub fn is_prop(char) -> bool; -/// } -/// -/// // You may also want to create a trait for easy access to the properties you define. -/// # fn main() {} -/// ``` -/// -/// # Effect -/// -/// - Implements the `CharProperty` trait and appropriate range trait -/// - Implements `FromStr` accepting either the abbr or long name, ascii case insensitive -/// - Implements `Display` using the `human` string -/// - Populates the module `abbr_names` with `pub use` bindings of variants to their abbr names -/// (Enumerated properties only) -/// - Populates the module `long_names` with `pub use` bindings of variants to their long names -/// (Enumerated properties only) -/// - Maintains all documentation comments and other `#[attributes]` as would be expected -/// (with some limitations, listed below) -/// -#[macro_export] -macro_rules! char_property { - - // == Enumerated Property == // - - ( - $(#[$prop_meta:meta])* - pub enum $prop_name:ident { - abbr => $prop_abbr:expr; - long => $prop_long:expr; - human => $prop_human:expr; - - $( - $(#[$variant_meta:meta])* - $variant_name:ident { - abbr => $variant_abbr:ident, - long => $variant_long:ident, - human => $variant_human:expr, - } - )* - } - - $(#[$abbr_mod_meta:meta])* - pub mod $abbr_mod:ident for abbr; - - $(#[$long_mod_meta:meta])* - pub mod $long_mod:ident for long; - - ) => { - $(#[$prop_meta])* - #[allow(bad_style)] - #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] - pub enum $prop_name { - $( $(#[$variant_meta])* $variant_name, )* - } - - $(#[$abbr_mod_meta])* - #[allow(bad_style)] - pub mod $abbr_mod { - $( pub use super::$prop_name::$variant_name as $variant_abbr; )* - } - - $(#[$long_mod_meta])* - #[allow(bad_style)] - pub mod $long_mod { - $( pub use super::$prop_name::$variant_name as $variant_long; )* - } - - char_property! { - __impl FromStr for $prop_name; - $( - stringify!($variant_abbr) => $prop_name::$variant_name; - stringify!($variant_long) => $prop_name::$variant_name; - )* - } - - char_property! { - __impl CharProperty for $prop_name; - $prop_abbr; - $prop_long; - $prop_human; - } - - char_property! { - __impl Display for $prop_name by EnumeratedCharProperty - } - - impl $crate::EnumeratedCharProperty for $prop_name { - fn all_values() -> &'static [$prop_name] { - const VALUES: &[$prop_name] = &[ - $( $prop_name::$variant_name, )* - ]; - VALUES - } - fn abbr_name(&self) -> &'static str { - match *self { - $( $prop_name::$variant_name => stringify!($variant_abbr), )* - } - } - fn long_name(&self) -> &'static str { - match *self { - $( $prop_name::$variant_name => stringify!($variant_long), )* - } - } - fn human_name(&self) -> &'static str { - match *self { - $( $prop_name::$variant_name => $variant_human, )* - } - } - } - }; - - // == Binary Property == // - - ( - $(#[$prop_meta:meta])* - pub struct $prop_name:ident(bool) { - abbr => $prop_abbr:expr; - long => $prop_long:expr; - human => $prop_human:expr; - - data_table_path => $data_path:expr; - } - - $(#[$is_fn_meta:meta])* - pub fn $is_fn:ident(char) -> bool; - - ) => { - $(#[$prop_meta])* - #[derive(Copy, Clone, Debug, Default, Eq, PartialEq, Hash)] - pub struct $prop_name(bool); - - $(#[$is_fn_meta])* - pub fn $is_fn(ch: char) -> bool { - $prop_name::of(ch).as_bool() - } - - impl $prop_name { - /// Get (struct) property value of the character. - pub fn of(ch: char) -> Self { - use $crate::tables::CharDataTable; - const TABLE: CharDataTable<()> = include!($data_path); - $prop_name(TABLE.contains(ch)) - } - - /// Get boolean property value of the character. - pub fn as_bool(&self) -> bool { self.0 } - } - - char_property! { - __impl FromStr for $prop_name; - // Yes - "y" => $prop_name(true); - "yes" => $prop_name(true); - "t" => $prop_name(true); - "true" => $prop_name(true); - // No - "n" => $prop_name(false); - "no" => $prop_name(false); - "f" => $prop_name(false); - "false" => $prop_name(false); - } - - char_property! { - __impl CharProperty for $prop_name; - $prop_abbr; - $prop_long; - $prop_human; - } - - impl $crate::TotalCharProperty for $prop_name { - fn of(ch: char) -> Self { Self::of(ch) } - } - - impl $crate::BinaryCharProperty for $prop_name { - fn as_bool(&self) -> bool { self.as_bool() } - } - - impl From<$prop_name> for bool { - fn from(prop: $prop_name) -> bool { prop.as_bool() } - } - - char_property! { - __impl Display for $prop_name by BinaryCharProperty - } - }; - - // == Shared == // - - ( - __impl CharProperty for $prop_name:ident; - $prop_abbr:expr; - $prop_long:expr; - $prop_human:expr; - ) => { - impl $crate::CharProperty for $prop_name { - fn prop_abbr_name() -> &'static str { $prop_abbr } - fn prop_long_name() -> &'static str { $prop_long } - fn prop_human_name() -> &'static str { $prop_human } - } - }; - - ( - __impl FromStr for $prop_name:ident; - $( $id:expr => $value:expr; )* - ) => { - #[allow(unreachable_patterns)] - impl $crate::__str::FromStr for $prop_name { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - match s { - $( $id => Ok($value), )* - $( s if s.eq_ignore_ascii_case($id) => Ok($value), )* - _ => Err(()), - } - } - } - }; - - ( __impl Display for $prop_name:ident by $trait:ident ) => { - impl $crate::__fmt::Display for $prop_name { - fn fmt(&self, f: &mut $crate::__fmt::Formatter) -> $crate::__fmt::Result { - $crate::$trait::human_name(self).fmt(f) - } - } - }; -} diff --git a/vendor/unic-char-property/src/pkg_info.rs b/vendor/unic-char-property/src/pkg_info.rs deleted file mode 100644 index a1ab2853f..000000000 --- a/vendor/unic-char-property/src/pkg_info.rs +++ /dev/null @@ -1,20 +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 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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/vendor/unic-char-property/src/property.rs b/vendor/unic-char-property/src/property.rs deleted file mode 100644 index 47d367f4d..000000000 --- a/vendor/unic-char-property/src/property.rs +++ /dev/null @@ -1,48 +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 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! Taxonomy and contracts for Character Property types. - -use core::fmt::Debug; -use core::hash::Hash; - -/// A Character Property, defined for some or all Unicode characters. -pub trait CharProperty: PartialCharProperty + Debug + Eq + Hash { - /// The *abbreviated name* of the property. - fn prop_abbr_name() -> &'static str; - - /// The *long name* of the property. - fn prop_long_name() -> &'static str; - - /// The *human-readable* name of the property. - fn prop_human_name() -> &'static str; -} - -/// A Character Property defined for some characters. -/// -/// Examples: `Decomposition_Type`, `Numeric_Type` -pub trait PartialCharProperty: Copy { - /// The property value for the character, or None. - fn of(ch: char) -> Option<Self>; -} - -/// A Character Property defined on all characters. -/// -/// Examples: `Age`, `Name`, `General_Category`, `Bidi_Class` -pub trait TotalCharProperty: PartialCharProperty + Default { - /// The property value for the character. - fn of(ch: char) -> Self; -} - -impl<T: TotalCharProperty> PartialCharProperty for T { - fn of(ch: char) -> Option<Self> { - Some(<Self as TotalCharProperty>::of(ch)) - } -} diff --git a/vendor/unic-char-property/src/range_types.rs b/vendor/unic-char-property/src/range_types.rs deleted file mode 100644 index e3cd47915..000000000 --- a/vendor/unic-char-property/src/range_types.rs +++ /dev/null @@ -1,104 +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 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! Character Property Range types. -//! -//! NOTE: At the moment, it is not possible to define a marker for all character property range -//! types and enforce their implementation from `CharProperty`. We need to fix this whenever the -//! compiler becomes able to do to so. - -use super::property::CharProperty; - -// == Enumerated/Catalog Types == - -/// A Character Property with enumerated values. -/// -/// This is similar to types *Enumeration* and *Catalog*, as defined in UAX#44. -/// -/// Usage Note: If the property is of type *Catalog*, it's recommended to (in some way) mark the -/// type as *non-exhaustive*, so that adding new variants to the `enum` type won't result in API -/// breakage. -pub trait EnumeratedCharProperty: Sized + CharProperty { - /// Exhaustive list of all property values. - fn all_values() -> &'static [Self]; - - /// The *abbreviated name* of the property value. - fn abbr_name(&self) -> &'static str; - - /// The *long name* of the property value. - fn long_name(&self) -> &'static str; - - /// The *human-readable name* of the property value. - fn human_name(&self) -> &'static str; -} - -// == Binary Types == - -/// A Character Property with binary values. -/// -/// Examples: `Alphabetic`, `Bidi_Mirrored`, `White_Space` -pub trait BinaryCharProperty: CharProperty { - /// The boolean value of the property value. - fn as_bool(&self) -> bool; - - /// The *abbreviated name* of the property value. - fn abbr_name(&self) -> &'static str { - if self.as_bool() { - "Y" - } else { - "N" - } - } - - /// The *long name* of the property value. - fn long_name(&self) -> &'static str { - if self.as_bool() { - "Yes" - } else { - "No" - } - } - - /// The *human-readable name* of the property value. - fn human_name(&self) -> &'static str { - if self.as_bool() { - "Yes" - } else { - "No" - } - } -} - -// == Numeric Types == - -/// Marker for numeric types accepted by `NumericCharProperty`. -pub trait NumericCharPropertyValue {} - -impl NumericCharPropertyValue for u8 {} - -/// A Character Property with numeric values. -/// -/// Examples: `Numeric_Value`, `Canonical_Combining_Class` -pub trait NumericCharProperty<NumericValue: NumericCharPropertyValue>: CharProperty { - /// The numeric value for the property value. - fn number(&self) -> NumericValue; -} - -// == Custom Types == - -/// A Character Property with custom values. -/// -/// Custom values means any non-enumerated, non-numeric value. -/// -/// Examples: `Age` property that returns a `UnicodeVersion` value. -pub trait CustomCharProperty<Value>: CharProperty { - /// The actual (inner) value for the property value. - fn actual(&self) -> Value; -} diff --git a/vendor/unic-char-property/src/tables.rs b/vendor/unic-char-property/src/tables.rs deleted file mode 100644 index ab419d552..000000000 --- a/vendor/unic-char-property/src/tables.rs +++ /dev/null @@ -1,117 +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 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! Character data tables used in UNIC. - -use unic_char_range::CharRange; - -/// A mapping from characters to some associated data. -/// -/// For the set case, use `()` as the associated value. -#[derive(Copy, Clone, Debug)] -pub enum CharDataTable<V: 'static> { - #[doc(hidden)] - Direct(&'static [(char, V)]), - #[doc(hidden)] - Range(&'static [(CharRange, V)]), -} - -impl<V> Default for CharDataTable<V> { - fn default() -> Self { - CharDataTable::Direct(&[]) - } -} - -impl<V> CharDataTable<V> { - /// Does this table contain a mapping for a character? - pub fn contains(&self, needle: char) -> bool { - match *self { - CharDataTable::Direct(table) => { - table.binary_search_by_key(&needle, |&(k, _)| k).is_ok() - } - CharDataTable::Range(table) => table - .binary_search_by(|&(range, _)| range.cmp_char(needle)) - .is_ok(), - } - } -} - -impl<V: Copy> CharDataTable<V> { - /// Find the associated data for a character in this table. - pub fn find(&self, needle: char) -> Option<V> { - match *self { - CharDataTable::Direct(table) => table - .binary_search_by_key(&needle, |&(k, _)| k) - .map(|idx| table[idx].1) - .ok(), - CharDataTable::Range(table) => table - .binary_search_by(|&(range, _)| range.cmp_char(needle)) - .map(|idx| table[idx].1) - .ok(), - } - } - - /// Find the range and the associated data for a character in the range table. - pub fn find_with_range(&self, needle: char) -> Option<(CharRange, V)> { - match *self { - CharDataTable::Direct(_) => None, - CharDataTable::Range(table) => table - .binary_search_by(|&(range, _)| range.cmp_char(needle)) - .map(|idx| table[idx]) - .ok(), - } - } -} - -impl<V: Copy + Default> CharDataTable<V> { - /// Find the associated data for a character in this table, or the default value if not entered. - pub fn find_or_default(&self, needle: char) -> V { - self.find(needle).unwrap_or_else(Default::default) - } -} - -/// Iterator for `CharDataTable`. Iterates over pairs `(CharRange, V)`. -#[derive(Debug)] -pub struct CharDataTableIter<'a, V: 'static>(&'a CharDataTable<V>, usize); - -impl<'a, V: Copy> Iterator for CharDataTableIter<'a, V> { - type Item = (CharRange, V); - - fn next(&mut self) -> Option<Self::Item> { - match *self.0 { - CharDataTable::Direct(arr) => { - if self.1 >= arr.len() { - None - } else { - let idx = self.1; - self.1 += 1; - let (ch, v) = arr[idx]; - Some((chars!(ch..=ch), v)) - } - } - CharDataTable::Range(arr) => { - if self.1 >= arr.len() { - None - } else { - let idx = self.1; - self.1 += 1; - Some(arr[idx]) - } - } - } - } -} - -impl<V> CharDataTable<V> { - /// Iterate over the entries in this table. Yields pairs `(CharRange, V)`. - pub fn iter(&self) -> CharDataTableIter<'_, V> { - CharDataTableIter(self, 0) - } -} diff --git a/vendor/unic-char-property/tests/bool_property_macro.rs b/vendor/unic-char-property/tests/bool_property_macro.rs deleted file mode 100644 index 7b452eea9..000000000 --- a/vendor/unic-char-property/tests/bool_property_macro.rs +++ /dev/null @@ -1,73 +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 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[macro_use] -extern crate unic_char_property; - -#[macro_use] -extern crate unic_char_range; - -char_property! { - /// This is a test property. - pub struct MyProp(bool) { - abbr => "mp"; - long => "My_Prop"; - human => "My Property"; - - data_table_path => "tables/property_table.rsv"; - } - - /// This is the shorthand function. - pub fn is_my_prop(char) -> bool; -} - -#[test] -fn test_basics() { - assert_eq!(MyProp::of('\u{0000}').as_bool(), false); - assert_eq!(MyProp::of('\u{0065}').as_bool(), true); - - assert_eq!(is_my_prop('\u{0000}'), false); - assert_eq!(is_my_prop('\u{0065}'), true); -} - -#[cfg_attr(feature = "cargo-clippy", allow(needless_bool))] -#[test] -fn test_into_bool() { - assert!(if MyProp::of('\u{0065}').into() { - true - } else { - false - }); -} - -#[test] -fn test_from_str() { - assert_eq!("y".parse(), Ok(MyProp(true))); - assert_eq!("yes".parse(), Ok(MyProp(true))); - assert_eq!("t".parse(), Ok(MyProp(true))); - assert_eq!("true".parse(), Ok(MyProp(true))); - - assert_eq!("N".parse(), Ok(MyProp(false))); - assert_eq!("NO".parse(), Ok(MyProp(false))); - assert_eq!("F".parse(), Ok(MyProp(false))); - assert_eq!("FALSE".parse(), Ok(MyProp(false))); -} - -#[test] -fn test_display() { - use unic_char_property::BinaryCharProperty; - - assert_eq!(MyProp::of('\u{0000}').abbr_name(), "N"); - assert_eq!(MyProp::of('\u{0065}').abbr_name(), "Y"); - assert_eq!(MyProp::of('\u{0000}').long_name(), "No"); - assert_eq!(MyProp::of('\u{0065}').long_name(), "Yes"); - assert_eq!(MyProp::of('\u{0000}').human_name(), "No"); - assert_eq!(MyProp::of('\u{0065}').human_name(), "Yes"); -} diff --git a/vendor/unic-char-property/tests/enum_property_macro.rs b/vendor/unic-char-property/tests/enum_property_macro.rs deleted file mode 100644 index e1caa41f5..000000000 --- a/vendor/unic-char-property/tests/enum_property_macro.rs +++ /dev/null @@ -1,87 +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 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[macro_use] -extern crate unic_char_property; - -use unic_char_property::PartialCharProperty; - -char_property! { - pub enum MyProp { - abbr => "mp"; - long => "My_Prop"; - human => "My Property"; - - /// Variants can have multi-line documentations, - /// and/or other attributes. - Variant1 { - abbr => V1, - long => Variant_1, - human => "Variant 1", - } - - /// One line works too, or... - Variant2 { - abbr => V2, - long => Variant_2, - human => "Variant 2", - } - - Variant3 { - abbr => V3, - long => Variant_3, - human => "Variant 3", - } - } - - pub mod abbr_names for abbr; - pub mod long_names for long; -} - -impl PartialCharProperty for MyProp { - fn of(_: char) -> Option<Self> { - None - } -} - -#[test] -fn test_basic_macro_use() { - use unic_char_property::EnumeratedCharProperty; - - assert_eq!(MyProp::Variant1, abbr_names::V1); - assert_eq!(MyProp::Variant2, abbr_names::V2); - assert_eq!(MyProp::Variant3, abbr_names::V3); - - assert_eq!(MyProp::Variant1, long_names::Variant_1); - assert_eq!(MyProp::Variant2, long_names::Variant_2); - assert_eq!(MyProp::Variant3, long_names::Variant_3); - - assert_eq!(MyProp::Variant1.abbr_name(), "V1"); - assert_eq!(MyProp::Variant2.abbr_name(), "V2"); - assert_eq!(MyProp::Variant3.abbr_name(), "V3"); - - assert_eq!(MyProp::Variant1.long_name(), "Variant_1"); - assert_eq!(MyProp::Variant2.long_name(), "Variant_2"); - assert_eq!(MyProp::Variant3.long_name(), "Variant_3"); - - assert_eq!(MyProp::Variant1.human_name(), "Variant 1"); - assert_eq!(MyProp::Variant2.human_name(), "Variant 2"); - assert_eq!(MyProp::Variant3.human_name(), "Variant 3"); -} - -#[test] -fn test_fromstr_ignores_case() { - use crate::abbr_names::V1; - - assert_eq!("variant_1".parse(), Ok(V1)); - assert_eq!("VaRiAnT_1".parse(), Ok(V1)); - assert_eq!("vArIaNt_1".parse(), Ok(V1)); - assert_eq!("VARIANT_1".parse(), Ok(V1)); -} diff --git a/vendor/unic-char-property/tests/tables/property_table.rsv b/vendor/unic-char-property/tests/tables/property_table.rsv deleted file mode 100644 index a4391b162..000000000 --- a/vendor/unic-char-property/tests/tables/property_table.rsv +++ /dev/null @@ -1,3 +0,0 @@ -CharDataTable::Range(&[ - (chars!(' '..='~'), ()), -]) diff --git a/vendor/unic-char-property/tests/tables_tests.rs b/vendor/unic-char-property/tests/tables_tests.rs deleted file mode 100644 index d20649587..000000000 --- a/vendor/unic-char-property/tests/tables_tests.rs +++ /dev/null @@ -1,43 +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 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[macro_use] -extern crate unic_char_range; - -use unic_char_property::tables::CharDataTable; - -#[test] -fn test_range_value_table() { - const TABLE: CharDataTable<u32> = CharDataTable::Range(&[ - (chars!('a'..='g'), 1), - (chars!('j'..='q'), 2), - (chars!('w'..='z'), 3), - ]); - for ch in chars!('a'..='g') { - assert_eq!(TABLE.find(ch), Some(1)); - assert_eq!(TABLE.find_or_default(ch), 1); - } - for ch in chars!('h'..='i') { - assert_eq!(TABLE.find(ch), None); - assert_eq!(TABLE.find_or_default(ch), 0); - } - for ch in chars!('j'..='q') { - assert_eq!(TABLE.find(ch), Some(2)); - assert_eq!(TABLE.find_or_default(ch), 2); - } - for ch in chars!('r'..='v') { - assert_eq!(TABLE.find(ch), None); - assert_eq!(TABLE.find_or_default(ch), 0); - } - for ch in chars!('x'..='z') { - assert_eq!(TABLE.find(ch), Some(3)); - assert_eq!(TABLE.find_or_default(ch), 3); - } -} |