Struct Literal

struct Literal { ... }

A single literal extracted from an Hir expression.

A literal is composed of two things:

Implementations

impl Literal

fn exact<B: Into<Vec<u8>>>(bytes: B) -> Literal

Returns a new exact literal containing the bytes given.

fn inexact<B: Into<Vec<u8>>>(bytes: B) -> Literal

Returns 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) -> usize

Returns the length of this literal in bytes.

fn is_empty(self: &Self) -> bool

Returns true if and only if this literal has zero bytes.

fn is_exact(self: &Self) -> bool

Returns 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_forward will 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 len bytes remain. If this literal has fewer than len bytes, 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 len bytes remain. If this literal has fewer than len bytes, 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) -> T

Returns the argument unchanged.

impl<T> ToOwned for Literal

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T, U> Into for Literal

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses 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>