icu_properties/
lib.rs

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