pub enum Unicode {}Expand description
A Unicode Standard Annex #31 profile (with LOW LINE, ZWJ, and ZWNJ removed).
§Character Set
This profile uses the unicode-ident crate.
- Start => any character that passes
is_xid_start(c)(except LOW LINE, ZWJ, and ZWNJ). - Continue => any character that passes
is_xid_continue(c)(except LOW LINE, ZWJ, and ZWNJ).
§About Low Line Omission
It’s confusing if the character profile contains a delimiter.
Instead, if you want an identifier that includes the low-line character, you should select such an identifier (from the presets, or by including it as a delimiter in a custom identifier).
We still “include” the character, we just want it to be treated specially.
§About ZWJ+ZWNJ Omissions
The zero-width joiner characters (U+200D and U+200C) have special usage within this profile, as detailed in the above specification. However, it requires extra processing to use them properly - we simply omit them.
If you wish to support these extended use-cases, you can create a custom
profile which allows these characters (simply by not disallowing them, just
call into unicode-ident functions). But you’ll have to implement
additional validation on top of the identifiers you form (perhaps as a
newtype).
In my reading of this standard, the zero-width characters are just not worth the headache. I really strongly recommend against their inclusion.
Trait Implementations§
impl CharProfile for Unicode
Source§impl Profile for Unicode
impl Profile for Unicode
Source§const APPEND_CLOSED: AppendClosed = AppendClosed::Fragment
const APPEND_CLOSED: AppendClosed = AppendClosed::Fragment
Source§type BaseProfile = Unicode
type BaseProfile = Unicode
Source§type Segmentation = Grapheme
type Segmentation = Grapheme
Source§fn is_ident_start(c: char) -> bool
fn is_ident_start(c: char) -> bool
Source§fn is_chunk_start(c: char) -> bool
fn is_chunk_start(c: char) -> bool
Source§fn in_profile(c: char) -> bool
fn in_profile(c: char) -> bool
Source§fn is_chunk_continue(c: char) -> bool
fn is_chunk_continue(c: char) -> bool
impl SubsetOf<Unicode> for Strict
Proof: Strict is a subset of the Unicode profile (strict has more restrictions).
impl SubsetOf<Unicode> for Ascii
Proof: ASCII is an obvious subset of Unicode.
impl SubsetOf<Unicode> for Unicode
Proof: It’s always safe to implement this against yourself.