Struct Literal

pub struct Literal { /* private fields */ }

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) -> &[u8]

Returns the bytes in this literal.

fn into_bytes(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) -> usize

Returns the length of this literal in bytes.

fn is_empty(&self) -> bool

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

fn is_exact(&self) -> bool

Returns true if and only if this literal is exact.

fn make_inexact(&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(&mut self)

Reverse the bytes in this literal.

fn extend(&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(&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(&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.

Trait Implementations

impl AsRef<[u8]> for Literal

fn as_ref(&self) -> &[u8]

impl Clone for Literal

fn clone(&self) -> Self

impl Debug for Literal

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

impl Eq for Literal

impl From<char> for Literal

fn from(ch: char) -> Literal

impl From<u8> for Literal

fn from(byte: u8) -> Literal

impl Ord for Literal

fn cmp(&self, other: &Self) -> Ordering

impl PartialEq for Literal

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

impl PartialOrd for Literal

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

impl StructuralPartialEq for Literal

Auto Trait Implementations

impl Freeze for Literal

impl RefUnwindSafe for Literal

impl Send for Literal

impl Sync for Literal

impl Unpin for Literal

impl UnsafeUnpin for Literal

impl UnwindSafe for Literal

Blanket Implementations

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

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for Literal where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for Literal where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> CloneToUninit for Literal where T: Clone,

unsafe fn clone_to_uninit(&self, dest: *mut u8)

impl<T> From<T> for Literal

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for Literal where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T, U> Into<U> for Literal where U: From<T>,

fn into(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<U> for Literal where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for Literal where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>