pub enum PatternToken<'s, P> {
    Placeholder(P),
    Literal {
        content: Cow<'s, str>,
        quoted: bool,
    },
}
Expand description

A token returned by the Parser.

Examples

use icu_pattern::{Parser, ParserOptions, PatternToken};

let input = "{0}, {1}";

let mut parser = Parser::new(
    input,
    ParserOptions {
        allow_raw_letters: false,
    },
);

let mut result = vec![];

while let Some(element) =
    parser.try_next().expect("Failed to advance iterator")
{
    result.push(element);
}

assert_eq!(
    result,
    &[
        PatternToken::Placeholder(0),
        PatternToken::Literal {
            content: ", ".into(),
            quoted: false
        },
        PatternToken::Placeholder(1),
    ]
);

Type parameters

  • P: A placeholder type which implements FromStr.

Lifetimes

  • s: The life time of an input string slice being parsed.

Variants§

§

Placeholder(P)

§

Literal

Fields

§content: Cow<'s, str>
§quoted: bool

Trait Implementations§

source§

impl<'s, P: Clone> Clone for PatternToken<'s, P>

source§

fn clone(&self) -> PatternToken<'s, P>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'s, P: Debug> Debug for PatternToken<'s, P>

source§

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

Formats the value using the given formatter. Read more
source§

impl<'s, P> From<(&'s str, bool)> for PatternToken<'s, P>

source§

fn from(input: (&'s str, bool)) -> Self

Converts to this type from the input type.
source§

impl<'s, P: PartialEq> PartialEq<PatternToken<'s, P>> for PatternToken<'s, P>

source§

fn eq(&self, other: &PatternToken<'s, P>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'s, P> StructuralPartialEq for PatternToken<'s, P>

Auto Trait Implementations§

§

impl<'s, P> RefUnwindSafe for PatternToken<'s, P>where P: RefUnwindSafe,

§

impl<'s, P> Send for PatternToken<'s, P>where P: Send,

§

impl<'s, P> Sync for PatternToken<'s, P>where P: Sync,

§

impl<'s, P> Unpin for PatternToken<'s, P>where P: Unpin,

§

impl<'s, P> UnwindSafe for PatternToken<'s, P>where P: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

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

Performs the conversion.