Struct version_number::parsers::original::Parser
source · pub struct Parser<'slice> { /* private fields */ }
Expand description
The orignal parser Parser 😊.
Example
use version_number::parsers::original::Parser;
use version_number::Version;
let parser = Parser::from_slice("1.2.3".as_bytes());
let version = parser.parse().unwrap();
assert_eq!(version, Version::new_full_version(1, 2,3));
Implementations§
source§impl<'slice> Parser<'slice>
impl<'slice> Parser<'slice>
sourcepub fn from_slice(slice: &'slice [u8]) -> Self
pub fn from_slice(slice: &'slice [u8]) -> Self
sourcepub fn parse(&self) -> Result<Version, OriginalParserError>
pub fn parse(&self) -> Result<Version, OriginalParserError>
Parse a two- or three component version number from the given input.
Example
use version_number::parsers::original::Parser;
use version_number::Version;
let parser = Parser::from_slice("1.2".as_bytes());
let version = parser.parse().unwrap();
assert_eq!(version, Version::new_base_version(1, 2));