pub struct Parser<'input> { /* private fields */ }Expand description
A recursive-descent parser for parsing version requirements.
Implementations§
Source§impl<'input> Parser<'input>
impl<'input> Parser<'input>
Sourcepub fn new(input: &'input str) -> Result<Parser<'input>, Error<'input>>
pub fn new(input: &'input str) -> Result<Parser<'input>, Error<'input>>
Construct a new parser for the given input.
Sourcepub fn component(&mut self) -> Result<Option<u64>, Error<'input>>
pub fn component(&mut self) -> Result<Option<u64>, Error<'input>>
Parse a single component.
Returns None if the component is a wildcard.
Sourcepub fn dot_component(&mut self) -> Result<(Option<u64>, bool), Error<'input>>
pub fn dot_component(&mut self) -> Result<(Option<u64>, bool), Error<'input>>
Optionally parse a dot, then a component.
The second component of the tuple indicates if a wildcard has been encountered, and is
always false if the first component is Some.
If a dot is not encountered, (None, false) is returned.
If a wildcard is encountered, (None, true) is returned.
Sourcepub fn dot_numeric(&mut self) -> Result<u64, Error<'input>>
pub fn dot_numeric(&mut self) -> Result<u64, Error<'input>>
Parse a dot, then a numeric.
Sourcepub fn dot_numeric_or_zero(&mut self) -> Result<u64, Error<'input>>
pub fn dot_numeric_or_zero(&mut self) -> Result<u64, Error<'input>>
Parse a dot, then a numeric. If the dot is missing, returns numeric 0. This allows us to parse versions such as “1.2”, which is a shorthand for “1.2.0”, or “1”, which is a shorthand for “1.0.0”. This is the difference between the parent and this fork.
Sourcepub fn identifier(&mut self) -> Result<Identifier, Error<'input>>
pub fn identifier(&mut self) -> Result<Identifier, Error<'input>>
Parse an string identifier.
Like, foo, or bar, or beta-1.