| 1 |
// This file is part of ICU4X. For terms of use, please see the file |
| 2 |
// called LICENSE at the top level of the ICU4X source tree |
| 3 |
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). |
| 4 |
|
| 5 |
// https://github.com/unicode-org/icu4x/blob/main/documents/process/boilerplate.md#library-annotations |
| 6 |
#![cfg_attr(not(any(test, doc)), no_std)] |
| 7 |
#![cfg_attr( |
| 8 |
not(test), |
| 9 |
deny( |
| 10 |
clippy::indexing_slicing, |
| 11 |
clippy::unwrap_used, |
| 12 |
clippy::expect_used, |
| 13 |
clippy::panic, |
| 14 |
) |
| 15 |
)] |
| 16 |
#![warn(missing_docs)] |
| 17 |
|
| 18 |
//! Definitions of [Unicode Properties] and APIs for |
| 19 |
//! retrieving property data in an appropriate data structure. |
| 20 |
//! |
| 21 |
//! This module is published as its own crate ([`icu_properties`](https://docs.rs/icu_properties/latest/icu_properties/)) |
| 22 |
//! and as part of the [`icu`](https://docs.rs/icu/latest/icu/) crate. See the latter for more details on the ICU4X project. |
| 23 |
//! |
| 24 |
//! APIs that return a [`CodePointSetData`] exist for binary properties and certain enumerated |
| 25 |
//! properties. |
| 26 |
//! |
| 27 |
//! APIs that return a [`CodePointMapData`] exist for certain enumerated properties. |
| 28 |
//! |
| 29 |
//! # Examples |
| 30 |
//! |
| 31 |
//! ## Property data as `CodePointSetData`s |
| 32 |
//! |
| 33 |
//! ``` |
| 34 |
//! use icu::properties::{CodePointSetData, CodePointMapData}; |
| 35 |
//! use icu::properties::props::{GeneralCategory, Emoji}; |
| 36 |
//! |
| 37 |
//! // A binary property as a `CodePointSetData` |
| 38 |
//! |
| 39 |
//! assert!(CodePointSetData::new::<Emoji>().contains('🎃')); // U+1F383 JACK-O-LANTERN |
| 40 |
//! assert!(!CodePointSetData::new::<Emoji>().contains('木')); // U+6728 |
| 41 |
//! |
| 42 |
//! // An individual enumerated property value as a `CodePointSetData` |
| 43 |
//! |
| 44 |
//! let line_sep_data = CodePointMapData::<GeneralCategory>::new() |
| 45 |
//! .get_set_for_value(GeneralCategory::LineSeparator); |
| 46 |
//! let line_sep = line_sep_data.as_borrowed(); |
| 47 |
//! |
| 48 |
//! assert!(line_sep.contains('\u{2028}')); |
| 49 |
//! assert!(!line_sep.contains('\u{2029}')); |
| 50 |
//! ``` |
| 51 |
//! |
| 52 |
//! ## Property data as `CodePointMapData`s |
| 53 |
//! |
| 54 |
//! ``` |
| 55 |
//! use icu::properties::CodePointMapData; |
| 56 |
//! use icu::properties::props::Script; |
| 57 |
//! |
| 58 |
//! assert_eq!(CodePointMapData::<Script>::new().get('🎃'), Script::Common); // U+1F383 JACK-O-LANTERN |
| 59 |
//! assert_eq!(CodePointMapData::<Script>::new().get('木'), Script::Han); // U+6728 |
| 60 |
//! ``` |
| 61 |
//! |
| 62 |
//! # Harfbuzz |
| 63 |
//! |
| 64 |
//! The `harfbuzz_traits` Cargo feature can be used to add implementations of the [`harfbuzz_traits`] to |
| 65 |
//! `CodePointMap<GeneralCategory>`, `CodePointMap<BidiMirroringGlyph>`, and to enable the |
| 66 |
//! [`script::HarfbuzzScriptData`] type. |
| 67 |
//! |
| 68 |
//! [`ICU4X`]: ../icu/index.html |
| 69 |
//! [Unicode Properties]: https://unicode-org.github.io/icu/userguide/strings/properties.html |
| 70 |
//! [`CodePointSetData`]: crate::CodePointSetData |
| 71 |
//! [`CodePointMapData`]: crate::CodePointMapData |
| 72 |
|
| 73 |
#[cfg(feature = "alloc")] |
| 74 |
extern crate alloc; |
| 75 |
|
| 76 |
mod code_point_set; |
| 77 |
pub use code_point_set::{CodePointSetData, CodePointSetDataBorrowed}; |
| 78 |
mod code_point_map; |
| 79 |
pub use code_point_map::{CodePointMapData, CodePointMapDataBorrowed}; |
| 80 |
mod emoji; |
| 81 |
pub use emoji::{EmojiSetData, EmojiSetDataBorrowed}; |
| 82 |
mod names; |
| 83 |
pub use names::{ |
| 84 |
PropertyNamesLong, PropertyNamesLongBorrowed, PropertyNamesShort, PropertyNamesShortBorrowed, |
| 85 |
PropertyParser, PropertyParserBorrowed, |
| 86 |
}; |
| 87 |
mod runtime; |
| 88 |
|
| 89 |
#[rustfmt::skip] |
| 90 |
mod enum_values; |
| 91 |
// NOTE: The Pernosco debugger has special knowledge |
| 92 |
// of the `CanonicalCombiningClass` struct inside the `props` |
| 93 |
// module. Please do not change the crate-module-qualified |
| 94 |
// name of that struct without coordination. |
| 95 |
pub mod props; |
| 96 |
pub mod provider; |
| 97 |
pub mod script; |
| 98 |
|
| 99 |
mod bidi; |
| 100 |
mod trievalue; |
| 101 |
|
| 102 |
mod private { |
| 103 |
pub trait Sealed {} |
| 104 |
} |
| 105 |
|
| 106 |
#[cfg(feature = "harfbuzz_traits")] |
| 107 |
mod harfbuzz; |
| 108 |
|
| 109 |
#[cfg(feature = "unstable")] |
| 110 |
#[cfg(feature = "alloc")] |
| 111 |
pub mod unicodeset_parse; |
| 112 |
|
| 113 |
#[cfg(not(feature = "unstable"))] |
| 114 |
#[cfg(feature = "alloc")] |
| 115 |
#[doc(hidden)] |
| 116 |
#[path = "unicodeset_parse/mod.rs"] |
| 117 |
pub mod unstable_unicodeset_parse; |