Skip to main content

Unicode

Enum Unicode 

Source
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§

Source§

impl CharProfile for Unicode

Source§

impl Profile for Unicode

Source§

const APPEND_CLOSED: AppendClosed = AppendClosed::Fragment

Whether or not a fragment containing characters in this profile are append-closed. Read more
Source§

type BaseProfile = Unicode

The underlying profile that this profile is based on. Read more
Source§

type Segmentation = Grapheme

The segmentation strategy that this profile uses. Read more
Source§

fn is_ident_start(c: char) -> bool

Whether or not the provided character can appear at the absolute start of an identifier. Read more
Source§

fn is_chunk_start(c: char) -> bool

Whether or not the provided character can appear at the start of a new chunk (e.g. right after a delimiter). Read more
Source§

fn in_profile(c: char) -> bool

Whether or not the provided character can appear at any point in a chunk. Read more
Source§

fn is_chunk_continue(c: char) -> bool

Whether or not the provided character is valid at any position after the first character of a chunk (a run of non-delimiter characters).
Source§

impl SubsetOf<Unicode> for Strict

Proof: Strict is a subset of the Unicode profile (strict has more restrictions).

Source§

impl SubsetOf<Unicode> for Ascii

Proof: ASCII is an obvious subset of Unicode.

Source§

impl SubsetOf<Unicode> for Unicode

Proof: It’s always safe to implement this against yourself.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.