Enum icu_pattern::PatternToken
source · 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 implementsFromStr
.
Lifetimes
s
: The life time of an input string slice being parsed.
Variants§
Trait Implementations§
source§impl<'s, P: Clone> Clone for PatternToken<'s, P>
impl<'s, P: Clone> Clone for PatternToken<'s, P>
source§fn clone(&self) -> PatternToken<'s, P>
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)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<'s, P: Debug> Debug for PatternToken<'s, P>
impl<'s, P: Debug> Debug for PatternToken<'s, P>
source§impl<'s, P: PartialEq> PartialEq<PatternToken<'s, P>> for PatternToken<'s, P>
impl<'s, P: PartialEq> PartialEq<PatternToken<'s, P>> for PatternToken<'s, P>
source§fn eq(&self, other: &PatternToken<'s, P>) -> bool
fn eq(&self, other: &PatternToken<'s, P>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more