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 more