Struct Literal
struct Literal { ... }
A single literal extracted from an Hir expression.
A literal is composed of two things:
- A sequence of bytes. No guarantees with respect to UTF-8 are provided.
In particular, even if the regex a literal is extracted from is UTF-8, the
literal extracted may not be valid UTF-8. (For example, if an
Extractorlimit resulted in trimming a literal in a way that splits a codepoint.) - Whether the literal is "exact" or not. An "exact" literal means that it
has not been trimmed, and may continue to be extended. If a literal is
"exact" after visiting the entire
Hirexpression, then this implies that the literal leads to a match state. (Although it doesn't necessarily imply all occurrences of the literal correspond to a match of the regex, since literal extraction ignores look-around assertions.)
Implementations
impl Literal
fn exact<B: Into<Vec<u8>>>(bytes: B) -> LiteralReturns a new exact literal containing the bytes given.
fn inexact<B: Into<Vec<u8>>>(bytes: B) -> LiteralReturns a new inexact literal containing the bytes given.
fn as_bytes(self: &Self) -> &[u8]Returns the bytes in this literal.
fn into_bytes(self: Self) -> Vec<u8>Yields ownership of the bytes inside this literal.
Note that this throws away whether the literal is "exact" or not.
fn len(self: &Self) -> usizeReturns the length of this literal in bytes.
fn is_empty(self: &Self) -> boolReturns true if and only if this literal has zero bytes.
fn is_exact(self: &Self) -> boolReturns true if and only if this literal is exact.
fn make_inexact(self: &mut Self)Marks this literal as inexact.
Inexact literals can never be extended. For example,
Seq::cross_forwardwill not extend inexact literals.fn reverse(self: &mut Self)Reverse the bytes in this literal.
fn extend(self: &mut Self, lit: &Literal)Extend this literal with the literal given.
If this literal is inexact, then this is a no-op.
fn keep_first_bytes(self: &mut Self, len: usize)Trims this literal such that only the first
lenbytes remain. If this literal has fewer thanlenbytes, then it remains unchanged. Otherwise, the literal is marked as inexact.fn keep_last_bytes(self: &mut Self, len: usize)Trims this literal such that only the last
lenbytes remain. If this literal has fewer thanlenbytes, then it remains unchanged. Otherwise, the literal is marked as inexact.
impl AsRef for Literal
fn as_ref(self: &Self) -> &[u8]
impl Clone for Literal
fn clone(self: &Self) -> Literal
impl Debug for Literal
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl Eq for Literal
impl Freeze for Literal
impl From for Literal
fn from(ch: char) -> Literal
impl From for Literal
fn from(byte: u8) -> Literal
impl Ord for Literal
fn cmp(self: &Self, other: &Literal) -> Ordering
impl PartialEq for Literal
fn eq(self: &Self, other: &Literal) -> bool
impl PartialOrd for Literal
fn partial_cmp(self: &Self, other: &Literal) -> Option<Ordering>
impl RefUnwindSafe for Literal
impl Send for Literal
impl StructuralPartialEq for Literal
impl Sync for Literal
impl Unpin for Literal
impl UnsafeUnpin for Literal
impl UnwindSafe for Literal
impl<T> Any for Literal
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for Literal
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for Literal
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for Literal
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> From for Literal
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for Literal
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T, U> Into for Literal
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for Literal
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for Literal
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>