Struct version_number::BaseVersion
source · 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: u64
A 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: u64
The 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 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for BaseVersion
impl Debug for BaseVersion
source§impl Display for BaseVersion
impl Display 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 · 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 ==
.source§impl PartialOrd for BaseVersion
impl PartialOrd for BaseVersion
source§fn partial_cmp(&self, other: &BaseVersion) -> Option<Ordering>
fn partial_cmp(&self, other: &BaseVersion) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more