pub struct Union<P1: Pattern, P2: Pattern>(pub P1, pub P2);Expand description
A pattern that matches either of the 2 patterns in a short-circuiting manner,
with self tried first. May be created by Pattern::or for convenience.
§Note
If you want to match either of N chars, use an array of them as a pattern instead, as this
struct has a general impl that may miss optimisations applicable to the case of [char; N]
being the pattern. However, unlike the array pattern, the combination of patterns using this
struct is not commutative, since the second pattern is only tried if the former has not been
found in the input.
Tuple Fields§
§0: P1§1: P2Trait Implementations§
Source§impl<P1: Pattern, P2: Pattern> Pattern for Union<P1, P2>
impl<P1: Pattern, P2: Pattern> Pattern for Union<P1, P2>
Source§fn immediate_match<I: Input>(&self, input: I) -> Result<(I, I), I>
fn immediate_match<I: Input>(&self, input: I) -> Result<(I, I), I>
The return values are (rest of the input, matched fragment at the beginning). Read more
Source§fn trailing_match<I: Input>(&self, input: I) -> Result<(I, I), I>
fn trailing_match<I: Input>(&self, input: I) -> Result<(I, I), I>
Like
Pattern::immediate_match, but matches at the end of input.
The return values are (the input before the match, the match) Read moreSource§fn first_match<I: Input>(&self, input: I) -> Result<(I, (I, I)), I>
fn first_match<I: Input>(&self, input: I) -> Result<(I, (I, I)), I>
The return values are (the match + rest of the input, (string before the match, the match)). Read more
Source§fn first_match_ex<I: Input>(&self, input: I) -> Result<(I, (I, I)), I>
fn first_match_ex<I: Input>(&self, input: I) -> Result<(I, (I, I)), I>
Like
Pattern::first_match, but the match is excluded from the rest of the input. Read moreSource§fn immediate_matches<I: Input>(&self, input: I) -> (I, I)
fn immediate_matches<I: Input>(&self, input: I) -> (I, I)
The return values are (rest of the input, contiguous matched fragments from the beginning). Read more
Source§fn immediate_matches_counted<I: Input>(&self, input: I) -> (I, (I, usize))
fn immediate_matches_counted<I: Input>(&self, input: I) -> (I, (I, usize))
Like
Pattern::immediate_matches, but also counts the number of matches. Read moreSource§fn trailing_matches_counted<I: Input>(&self, input: I) -> (I, usize)
fn trailing_matches_counted<I: Input>(&self, input: I) -> (I, usize)
Like
Pattern::immediate_matches_counted, but matches at the end of input,
and doesn’t return the matched fragment of the input. Read moreAuto Trait Implementations§
impl<P1, P2> Freeze for Union<P1, P2>
impl<P1, P2> RefUnwindSafe for Union<P1, P2>where
P1: RefUnwindSafe,
P2: RefUnwindSafe,
impl<P1, P2> Send for Union<P1, P2>
impl<P1, P2> Sync for Union<P1, P2>
impl<P1, P2> Unpin for Union<P1, P2>
impl<P1, P2> UnwindSafe for Union<P1, P2>where
P1: UnwindSafe,
P2: 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