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// 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")]
74extern crate alloc;
75
76mod code_point_set;
77pub use code_point_set::{CodePointSetData, CodePointSetDataBorrowed};
78mod code_point_map;
79pub use code_point_map::{CodePointMapData, CodePointMapDataBorrowed};
80mod emoji;
81pub use emoji::{EmojiSetData, EmojiSetDataBorrowed};
82mod names;
83pub use names::{
84 PropertyNamesLong, PropertyNamesLongBorrowed, PropertyNamesShort, PropertyNamesShortBorrowed,
85 PropertyParser, PropertyParserBorrowed,
86};
87mod runtime;
88
89// NOTE: The Pernosco debugger has special knowledge
90// of the `CanonicalCombiningClass` struct inside the `props`
91// module. Please do not change the crate-module-qualified
92// name of that struct without coordination.
93pub mod props;
94pub mod provider;
95pub mod script;
96
97mod bidi;
98mod trievalue;
99
100mod private {
101 pub trait Sealed {}
102}
103
104#[cfg(feature = "harfbuzz_traits")]
105mod harfbuzz;