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. See the [`sets`] module for more details. |
13 | //! |
14 | //! APIs that return a [`CodePointMapData`] exist for certain enumerated properties. See the |
15 | //! [`maps`] module for more details. |
16 | //! |
17 | //! # Examples |
18 | //! |
19 | //! ## Property data as `CodePointSetData`s |
20 | //! |
21 | //! ``` |
22 | //! use icu::properties::{maps, sets, GeneralCategory}; |
23 | //! |
24 | //! // A binary property as a `CodePointSetData` |
25 | //! |
26 | //! assert!(sets::emoji().contains('🎃' )); // U+1F383 JACK-O-LANTERN |
27 | //! assert!(!sets::emoji().contains('木' )); // U+6728 |
28 | //! |
29 | //! // An individual enumerated property value as a `CodePointSetData` |
30 | //! |
31 | //! let line_sep_data = maps::general_category() |
32 | //! .get_set_for_value(GeneralCategory::LineSeparator); |
33 | //! let line_sep = line_sep_data.as_borrowed(); |
34 | //! |
35 | //! assert!(line_sep.contains32(0x2028)); |
36 | //! assert!(!line_sep.contains32(0x2029)); |
37 | //! ``` |
38 | //! |
39 | //! ## Property data as `CodePointMapData`s |
40 | //! |
41 | //! ``` |
42 | //! use icu::properties::{maps, Script}; |
43 | //! |
44 | //! assert_eq!(maps::script().get('🎃' ), Script::Common); // U+1F383 JACK-O-LANTERN |
45 | //! assert_eq!(maps::script().get('木' ), Script::Han); // U+6728 |
46 | //! ``` |
47 | //! |
48 | //! [`ICU4X`]: ../icu/index.html |
49 | //! [Unicode Properties]: https://unicode-org.github.io/icu/userguide/strings/properties.html |
50 | //! [`CodePointSetData`]: crate::sets::CodePointSetData |
51 | //! [`CodePointMapData`]: crate::maps::CodePointMapData |
52 | //! [`sets`]: crate::sets |
53 | |
54 | // https://github.com/unicode-org/icu4x/blob/main/documents/process/boilerplate.md#library-annotations |
55 | #![cfg_attr (not(any(test, feature = "std" )), 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 | missing_debug_implementations, |
66 | ) |
67 | )] |
68 | #![warn (missing_docs)] |
69 | |
70 | extern crate alloc; |
71 | |
72 | #[cfg (feature = "bidi" )] |
73 | pub mod bidi; |
74 | |
75 | mod error; |
76 | pub mod maps; |
77 | |
78 | // NOTE: The Pernosco debugger has special knowledge |
79 | // of the `CanonicalCombiningClass` struct inside the `props` |
80 | // module. Please do not change the crate-module-qualified |
81 | // name of that struct without coordination. |
82 | mod props; |
83 | |
84 | pub mod bidi_data; |
85 | pub mod exemplar_chars; |
86 | pub mod provider; |
87 | pub(crate) mod runtime; |
88 | #[allow (clippy::exhaustive_structs)] // TODO |
89 | pub mod script; |
90 | pub mod sets; |
91 | mod trievalue; |
92 | |
93 | pub use props::{ |
94 | BidiClass, CanonicalCombiningClass, EastAsianWidth, GeneralCategory, GeneralCategoryGroup, |
95 | GraphemeClusterBreak, HangulSyllableType, IndicSyllabicCategory, JoiningType, LineBreak, |
96 | Script, SentenceBreak, WordBreak, |
97 | }; |
98 | |
99 | /// Module for working with the names of property values |
100 | pub mod names { |
101 | pub use crate::props::{ |
102 | PropertyEnumToValueNameLinearMapper, PropertyEnumToValueNameLinearMapperBorrowed, |
103 | }; |
104 | pub use crate::props::{ |
105 | PropertyEnumToValueNameLinearTiny4Mapper, PropertyEnumToValueNameLinearTiny4MapperBorrowed, |
106 | }; |
107 | pub use crate::props::{ |
108 | PropertyEnumToValueNameSparseMapper, PropertyEnumToValueNameSparseMapperBorrowed, |
109 | }; |
110 | pub use crate::props::{PropertyValueNameToEnumMapper, PropertyValueNameToEnumMapperBorrowed}; |
111 | } |
112 | |
113 | pub use error::PropertiesError; |
114 | |
115 | #[doc (no_inline)] |
116 | pub use PropertiesError as Error; |
117 | |