pub struct BaseVersion {
pub major: u64,
pub minor: u64,
}Expand description
A two-component MAJOR.MINOR version.
This version number is a subset of semver. In particular, it consists of the MAJOR
and MINOR components, and leaves out the PATCH and additional labels for pre-release
and build metadata.
If you require a version number which also includes the PATCH number,
please see the FullVersion variant. For a semver compliant parser, you should use
the semver crate instead.
Fields§
§major: u64A major version is incremented when backwards incompatible changes are made to a public
API.
When this number equals 0, the version is considered an unstable initial development
version.
minor: u64The minor version is incremented when backwards compatibles changes are made to a public
API.
When the version number is considered an unstable initial development version, it may also be incremented for backwards incompatible changes.
Implementations§
Source§impl BaseVersion
impl BaseVersion
Sourcepub fn new(major: u64, minor: u64) -> Self
pub fn new(major: u64, minor: u64) -> Self
Instantiate a two component, version number with MAJOR and MINOR components.
See BaseVersion for more.
Sourcepub fn parse(input: &str) -> Result<Self, ParserError>
pub fn parse(input: &str) -> Result<Self, ParserError>
Parse a two component, major.minor version number from a given input.
Returns a ParserError if it fails to parse.
Sourcepub fn to_full_version_lossy(self) -> FullVersion
pub fn to_full_version_lossy(self) -> FullVersion
Convert this base version to a full version.
This conversion is lossy because the patch value is not known to this BaseVersion, and
will initialize as 0.
Sourcepub fn map<U, F>(self, fun: F) -> Uwhere
F: FnOnce(Self) -> U,
pub fn map<U, F>(self, fun: F) -> Uwhere
F: FnOnce(Self) -> U,
Map a BaseVersion to U.
§Example
use version_number::BaseVersion;
// 🧑🔬
fn invert_version(v: BaseVersion) -> BaseVersion {
BaseVersion::new(v.minor, v.major)
}
let example = BaseVersion::new(1, 2);
assert_eq!(example.map(invert_version), BaseVersion::new(2, 1));Trait Implementations§
Source§impl Clone for BaseVersion
impl Clone for BaseVersion
Source§fn clone(&self) -> BaseVersion
fn clone(&self) -> BaseVersion
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for BaseVersion
Source§impl Debug for BaseVersion
impl Debug for BaseVersion
Source§impl Display for BaseVersion
impl Display for BaseVersion
impl Eq for BaseVersion
Source§impl Hash for BaseVersion
impl Hash for BaseVersion
Source§impl Ord for BaseVersion
impl Ord for BaseVersion
Source§fn cmp(&self, other: &BaseVersion) -> Ordering
fn cmp(&self, other: &BaseVersion) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for BaseVersion
impl PartialEq for BaseVersion
Source§fn eq(&self, other: &BaseVersion) -> bool
fn eq(&self, other: &BaseVersion) -> bool
self and other values to be equal, and is used by ==.