Struct litrs::StringLit[][src]

pub struct StringLit<B: Buffer> { /* fields omitted */ }
Expand description

A string or raw string literal, e.g. "foo", "Grüße" or r#"a🦊c"d🦀f"#.

See the reference for more information.

Implementations

impl<B: Buffer> StringLit<B>[src]

pub fn parse(input: B) -> Result<Self, Error>[src]

Parses the input as a (raw) string literal. Returns an error if the input is invalid or represents a different kind of literal.

pub fn value(&self) -> &str[src]

Returns the string value this literal represents (where all escapes have been turned into their respective values).

pub fn into_value(self) -> B::Cow[src]

Like value but returns a potentially owned version of the value.

The return value is either Cow<'static, str> if B = String, or Cow<'a, str> if B = &'a str.

pub fn is_raw_string(&self) -> bool[src]

Returns whether this literal is a raw string literal (starting with r).

impl StringLit<&str>[src]

pub fn into_owned(self) -> StringLit<String>[src]

Makes a copy of the underlying buffer and returns the owned version of Self.

Trait Implementations

impl<B: Clone + Buffer> Clone for StringLit<B>[src]

fn clone(&self) -> StringLit<B>[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<B: Debug + Buffer> Debug for StringLit<B>[src]

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

Formats the value using the given formatter. Read more

impl<B: Buffer> Display for StringLit<B>[src]

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

Formats the value using the given formatter. Read more

impl<B: PartialEq + Buffer> PartialEq<StringLit<B>> for StringLit<B>[src]

fn eq(&self, other: &StringLit<B>) -> bool[src]

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

fn ne(&self, other: &StringLit<B>) -> bool[src]

This method tests for !=.

impl<B: Eq + Buffer> Eq for StringLit<B>[src]

impl<B: Buffer> StructuralEq for StringLit<B>[src]

impl<B: Buffer> StructuralPartialEq for StringLit<B>[src]

Auto Trait Implementations

impl<B> RefUnwindSafe for StringLit<B> where
    B: RefUnwindSafe

impl<B> Send for StringLit<B> where
    B: Send

impl<B> Sync for StringLit<B> where
    B: Sync

impl<B> Unpin for StringLit<B> where
    B: Unpin

impl<B> UnwindSafe for StringLit<B> where
    B: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T> ToString for T where
    T: Display + ?Sized
[src]

pub default fn to_string(&self) -> String[src]

Converts the given value to a String. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.