pub trait Pattern {
type Err: Debug;
// Required method
fn matches(&mut self, c: char, s: &str) -> Result<bool, Self::Err>;
// Provided methods
fn len(&self) -> NonZeroUsize { ... }
fn sep(&self) -> Sep { ... }
}Required Associated Types§
Required Methods§
Sourcefn matches(&mut self, c: char, s: &str) -> Result<bool, Self::Err>
fn matches(&mut self, c: char, s: &str) -> Result<bool, Self::Err>
Try matching a char in a pattern
§Arguments
c- The currentchar, guaranteed to be the firstcharinss- The current&str, a substring of some length afterc
In slice or
split: match until the first true result
In trim_by: match until the first false result
len() is a suggestion for s.len().
However s is not guaranteed to have the same length as self.len(),
since joining multiple patterns can increase s.len(),
and corner cases will decrease s.len().
Provided Methods§
Sourcefn len(&self) -> NonZeroUsize
fn len(&self) -> NonZeroUsize
Determines how many chars to look ahead, default 1.
The iterator will not stop prematurely because of look-ahead.