Struct version_number::FullVersion
source · pub struct FullVersion {
pub major: u64,
pub minor: u64,
pub patch: u64,
}
Expand description
A three-component MAJOR.MINOR.PATCH
version.
This version number is a subset of semver
. In particular, it consists of the MAJOR
.
MINOR
and PATCH
components, and leaves out the additional labels for pre-release and build
metadata.
If you require a version number which also discards the PATCH
number,
please see the BaseVersion
variant.
For a semver
compliant parser, you should use the semver
crate
instead.
§Converting to a semver::Version
This version type may be converted to a semver::Version
using the From
trait, assuming
the semver
feature is enabled.
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.
patch: u64
The patch
version is incremented when backwards compatibles bug fixes are made.
Implementations§
source§impl FullVersion
impl FullVersion
sourcepub fn new(major: u64, minor: u64, patch: u64) -> Self
pub fn new(major: u64, minor: u64, patch: u64) -> Self
Instantiate a three component, version number with MAJOR
, MINOR
and PATCH
components.
See FullVersion
for more.
sourcepub fn parse(input: &str) -> Result<Self, ParserError>
pub fn parse(input: &str) -> Result<Self, ParserError>
Parse a three component, major.minor.patch
version number from a given input.
Returns a ParserError
if it fails to parse.
sourcepub fn to_base_version_lossy(self) -> BaseVersion
pub fn to_base_version_lossy(self) -> BaseVersion
Convert this full version to a base version.
This conversion is lossy because the patch
value is lost upon conversion.
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 FullVersion
to U
.
§Example
use version_number::FullVersion;
// 🧑🔬
fn invert_version(v: FullVersion) -> FullVersion {
FullVersion::new(v.patch, v.minor, v.major)
}
let example = FullVersion::new(1, 2, 3);
assert_eq!(example.map(invert_version), FullVersion::new(3, 2, 1));
Trait Implementations§
source§impl Clone for FullVersion
impl Clone for FullVersion
source§fn clone(&self) -> FullVersion
fn clone(&self) -> FullVersion
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for FullVersion
impl Debug for FullVersion
source§impl Display for FullVersion
impl Display for FullVersion
source§impl Hash for FullVersion
impl Hash for FullVersion
source§impl Ord for FullVersion
impl Ord for FullVersion
source§fn cmp(&self, other: &FullVersion) -> Ordering
fn cmp(&self, other: &FullVersion) -> 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 FullVersion
impl PartialEq for FullVersion
source§fn eq(&self, other: &FullVersion) -> bool
fn eq(&self, other: &FullVersion) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for FullVersion
impl PartialOrd for FullVersion
source§fn partial_cmp(&self, other: &FullVersion) -> Option<Ordering>
fn partial_cmp(&self, other: &FullVersion) -> 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