1 | //! Utilities for working with the [General Security Profile](https://www.unicode.org/reports/tr39/#General_Security_Profile) |
2 | //! for identifiers |
3 | |
4 | use crate::tables::identifier; |
5 | |
6 | pub use identifier::IdentifierType; |
7 | |
8 | /// Methods for determining characters not restricted from use for identifiers. |
9 | pub trait GeneralSecurityProfile { |
10 | /// Returns whether the character is not restricted from use for identifiers. |
11 | fn identifier_allowed(self) -> bool; |
12 | |
13 | /// Returns the [identifier type](https://www.unicode.org/reports/tr39/#Identifier_Status_and_Type) |
14 | fn identifier_type(self) -> Option<IdentifierType>; |
15 | } |
16 | |
17 | impl GeneralSecurityProfile for char { |
18 | #[inline ] |
19 | fn identifier_allowed(self) -> bool { |
20 | identifier::identifier_status_allowed(self) |
21 | } |
22 | #[inline ] |
23 | fn identifier_type(self) -> Option<IdentifierType> { |
24 | identifier::identifier_type(self) |
25 | } |
26 | } |
27 | |