summaryrefslogtreecommitdiffstats
path: root/vendor/unicode-security/src/general_security_profile.rs
blob: 7daedddab2a84e44e95c00eb539b9591d9048ebe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//! Utilities for working with the [General Security Profile](https://www.unicode.org/reports/tr39/#General_Security_Profile)
//! for identifiers

use crate::tables::identifier;

pub use identifier::IdentifierType;

/// Methods for determining characters not restricted from use for identifiers.
pub trait GeneralSecurityProfile {
    /// Returns whether the character is not restricted from use for identifiers.
    fn identifier_allowed(self) -> bool;

    /// Returns the [identifier type](https://www.unicode.org/reports/tr39/#Identifier_Status_and_Type)
    fn identifier_type(self) -> Option<IdentifierType>;
}

impl GeneralSecurityProfile for char {
    #[inline]
    fn identifier_allowed(self) -> bool {
        identifier::identifier_status_allowed(self)
    }
    #[inline]
    fn identifier_type(self) -> Option<IdentifierType> {
        identifier::identifier_type(self)
    }
}