semver_parser::parser

Struct Parser

Source
pub struct Parser<'input> { /* private fields */ }
Expand description

A recursive-descent parser for parsing version requirements.

Implementations§

Source§

impl<'input> Parser<'input>

Source

pub fn new(input: &'input str) -> Result<Parser<'input>, Error<'input>>

Construct a new parser for the given input.

Source

pub fn component(&mut self) -> Result<Option<u64>, Error<'input>>

Parse a single component.

Returns None if the component is a wildcard.

Source

pub fn numeric(&mut self) -> Result<u64, Error<'input>>

Parse a single numeric.

Source

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.

Source

pub fn dot_numeric(&mut self) -> Result<u64, Error<'input>>

Parse a dot, then a numeric.

Source

pub fn identifier(&mut self) -> Result<Identifier, Error<'input>>

Parse an string identifier.

Like, foo, or bar, or beta-1.

Source

pub fn version(&mut self) -> Result<Version, Error<'input>>

Parse a version.

Like, 1.0.0 or 3.0.0-beta.1.

Source

pub fn is_eof(&mut self) -> bool

Check if we have reached the end of input.

Source

pub fn tail(&mut self) -> Result<Vec<Token<'input>>, Error<'input>>

Get the rest of the tokens in the parser.

Useful for debugging.

Auto Trait Implementations§

§

impl<'input> Freeze for Parser<'input>

§

impl<'input> RefUnwindSafe for Parser<'input>

§

impl<'input> Send for Parser<'input>

§

impl<'input> Sync for Parser<'input>

§

impl<'input> Unpin for Parser<'input>

§

impl<'input> UnwindSafe for Parser<'input>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.