Struct regex_syntax::CharClass [-] [+] [src]

pub struct CharClass {
    // some fields omitted
}

A character class.

A character class has a canonical format that the parser guarantees. Its canonical format is defined by the following invariants:

  1. Given any Unicode scalar value, it is matched by at most one character range in a canonical character class.
  2. Every adjacent character range is separated by at least one Unicode scalar value.
  3. Given any pair of character ranges r1 and r2, if r1.end < r2.start, then r1 comes before r2 in a canonical character class.

In sum, any CharClass produced by this crate's parser is a sorted sequence of non-overlapping ranges. This makes it possible to test whether a character is matched by a class with a binary search.

Additionally, a character class may be marked case insensitive. If it's case insensitive, then:

  1. Simple case folding has been applied to all ranges.
  2. Simple case folding must be applied to a character before testing whether it matches the character class.

Methods

impl CharClass

fn matches(&self, c: char) -> bool

Returns true if c is matched by this character class.

If this character class is case insensitive, then simple case folding is applied to c before checking for a match.

fn is_case_insensitive(&self) -> bool

Returns true if this character class should be matched case insensitively.

When true, simple case folding has already been applied to the class.

Trait Implementations

impl Deref for CharClass

type Target = Vec<ClassRange>

fn deref(&self) -> &Vec<ClassRange>

impl IntoIterator for CharClass

type Item = ClassRange

type IntoIter = IntoIter<ClassRange>

fn into_iter(self) -> IntoIter<ClassRange>

impl<'a> IntoIterator for &'a CharClass

type Item = &'a ClassRange

type IntoIter = Iter<'a, ClassRange>

fn into_iter(self) -> Iter<'a, ClassRange>

impl Display for CharClass

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

Derived Implementations

impl Eq for CharClass

impl PartialEq for CharClass

fn eq(&self, __arg_0: &CharClass) -> bool

fn ne(&self, __arg_0: &CharClass) -> bool

impl Debug for CharClass

fn fmt(&self, __arg_0: &mut Formatter) -> Result

impl Clone for CharClass

fn clone(&self) -> CharClass

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