Struct regex_syntax::Literals [] [src]

pub struct Literals { /* fields omitted */ }

A set of literal byte strings extracted from a regular expression.

Every member of the set is a Lit, which is represented by a Vec<u8>. (Notably, it may contain invalid UTF-8.) Every member is said to be either complete or cut. A complete literal means that it extends until the beginning (or end) of the regular expression. In some circumstances, this can be used to indicate a match in the regular expression.

Note that a key aspect of literal extraction is knowing when to stop. It is not feasible to blindly extract all literals from a regular expression, even if there are finitely many. For example, the regular expression [0-9]{10} has 10^10 distinct literals. For this reason, literal extraction is bounded to some low number by default using heuristics, but the limits can be tweaked.

Methods

impl Literals
[src]

[src]

Returns a new empty set of literals using default limits.

[src]

Get the approximate size limit (in bytes) of this set.

[src]

Set the approximate size limit (in bytes) of this set.

If extracting a literal would put the set over this limit, then extraction stops.

The new limits will only apply to additions to this set. Existing members remain unchanged, even if the set exceeds the new limit.

[src]

Get the character class size limit for this set.

[src]

Limits the size of character(or byte) classes considered.

A value of 0 prevents all character classes from being considered.

This limit also applies to case insensitive literals, since each character in the case insensitive literal is converted to a class, and then case folded.

The new limits will only apply to additions to this set. Existing members remain unchanged, even if the set exceeds the new limit.

[src]

Returns the set of literals as a slice. Its order is unspecified.

[src]

Returns the length of the smallest literal.

Returns None is there are no literals in the set.

[src]

Returns true if all members in this set are complete.

[src]

Returns true if any member in this set is complete.

[src]

Returns true if this set contains an empty literal.

[src]

Returns true if this set is empty or if all of its members is empty.

[src]

Returns a new empty set of literals using this set's limits.

[src]

Returns the longest common prefix of all members in this set.

[src]

Returns the longest common suffix of all members in this set.

[src]

Returns a new set of literals with the given number of bytes trimmed from the suffix of each literal.

If any literal would be cut out completely by trimming, then None is returned.

Any duplicates that are created as a result of this transformation are removed.

[src]

Returns a new set of prefixes of this set of literals that are guaranteed to be unambiguous.

Any substring match with a member of the set is returned is guaranteed to never overlap with a substring match of another member of the set at the same starting position.

Given any two members of the returned set, neither is a substring of the other.

[src]

Returns a new set of suffixes of this set of literals that are guaranteed to be unambiguous.

Any substring match with a member of the set is returned is guaranteed to never overlap with a substring match of another member of the set at the same ending position.

Given any two members of the returned set, neither is a substring of the other.

[src]

Unions the prefixes from the given expression to this set.

If prefixes could not be added (for example, this set would exceed its size limits or the set of prefixes from expr includes the empty string), then false is returned.

Note that prefix literals extracted from expr are said to be complete if and only if the literal extends from the beginning of expr to the end of expr.

[src]

Unions the suffixes from the given expression to this set.

If suffixes could not be added (for example, this set would exceed its size limits or the set of suffixes from expr includes the empty string), then false is returned.

Note that prefix literals extracted from expr are said to be complete if and only if the literal extends from the end of expr to the beginning of expr.

[src]

Unions this set with another set.

If the union would cause the set to exceed its limits, then the union is skipped and it returns false. Otherwise, if the union succeeds, it returns true.

[src]

Extends this set with another set.

The set of literals is extended via a cross product.

If a cross product would cause this set to exceed its limits, then the cross product is skipped and it returns false. Otherwise, if the cross product succeeds, it returns true.

[src]

Extends each literal in this set with the bytes given.

If the set is empty, then the given literal is added to the set.

If adding any number of bytes to all members of this set causes a limit to be exceeded, then no bytes are added and false is returned. If a prefix of bytes can be fit into this set, then it is used and all resulting literals are cut.

[src]

Adds the given literal to this set.

Returns false if adding this literal would cause the class to be too big.

[src]

Extends each literal in this set with the character class given.

Returns false if the character class was too big to add.

[src]

Extends each literal in this set with the byte class given.

Returns false if the byte class was too big to add.

[src]

Cuts every member of this set. When a member is cut, it can never be extended.

[src]

Reverses all members in place.

[src]

Clears this set of all members.

Trait Implementations

impl Clone for Literals
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Eq for Literals
[src]

impl PartialEq for Literals
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl Debug for Literals
[src]

[src]

Formats the value using the given formatter.