Enum regex_syntax::hir::Class

source ·
pub enum Class {
    Unicode(ClassUnicode),
    Bytes(ClassBytes),
}
Expand description

The high-level intermediate representation of a character class.

A character class corresponds to a set of characters. A character is either defined by a Unicode scalar value or a byte. Unicode characters are used by default, while bytes are used when Unicode mode (via the u flag) is disabled.

A character class, regardless of its character type, is represented by a sequence of non-overlapping non-adjacent ranges of characters.

Note that unlike Literal, a Bytes variant may be produced even when it exclusively matches valid UTF-8. This is because a Bytes variant represents an intention by the author of the regular expression to disable Unicode mode, which in turn impacts the semantics of case insensitive matching. For example, (?i)k and (?i-u)k will not match the same set of strings.

Variants§

§

Unicode(ClassUnicode)

A set of characters represented by Unicode scalar values.

§

Bytes(ClassBytes)

A set of characters represented by arbitrary bytes (one byte per character).

Implementations§

source§

impl Class

source

pub fn case_fold_simple(&mut self)

Apply Unicode simple case folding to this character class, in place. The character class will be expanded to include all simple case folded character variants.

If this is a byte oriented character class, then this will be limited to the ASCII ranges A-Z and a-z.

source

pub fn negate(&mut self)

Negate this character class in place.

After completion, this character class will contain precisely the characters that weren’t previously in the class.

source

pub fn is_always_utf8(&self) -> bool

Returns true if and only if this character class will only ever match valid UTF-8.

A character class can match invalid UTF-8 only when the following conditions are met:

  1. The translator was configured to permit generating an expression that can match invalid UTF-8. (By default, this is disabled.)
  2. Unicode mode (via the u flag) was disabled either in the concrete syntax or in the parser builder. By default, Unicode mode is enabled.

Trait Implementations§

source§

impl Clone for Class

source§

fn clone(&self) -> Class

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Class

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq<Class> for Class

source§

fn eq(&self, other: &Class) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Class

source§

impl StructuralEq for Class

source§

impl StructuralPartialEq for Class

Auto Trait Implementations§

§

impl RefUnwindSafe for Class

§

impl Send for Class

§

impl Sync for Class

§

impl Unpin for Class

§

impl UnwindSafe for Class

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.