pub struct Version {
pub major: u64,
pub minor: u64,
pub patch: u64,
pub pre: Vec<Identifier>,
pub build: Vec<Identifier>,
}
Expand description
Represents a version number conforming to the semantic versioning scheme.
Fields
major: u64
The major version, to be incremented on incompatible changes.
minor: u64
The minor version, to be incremented when functionality is added in a backwards-compatible manner.
patch: u64
The patch version, to be incremented when backwards-compatible bug fixes are made.
pre: Vec<Identifier>
The pre-release version identifier, if one exists.
build: Vec<Identifier>
The build metadata, ignored when determining version precedence.
Implementations
sourceimpl Version
impl Version
sourcepub fn new(major: u64, minor: u64, patch: u64) -> Version
pub fn new(major: u64, minor: u64, patch: u64) -> Version
Contructs the simple case without pre or build.
sourcepub fn parse(version: &str) -> Result<Version, SemVerError>
pub fn parse(version: &str) -> Result<Version, SemVerError>
Parse a string into a semver object.
Errors
Returns an error variant if the input could not be parsed as a semver object.
In general, this means that the provided string does not conform to the semver spec.
An error for overflow is returned if any numeric component is larger than what can be
stored in u64
.
The following are examples for other common error causes:
1.0
- too few numeric components are used. Exactly 3 are expected.1.0.01
- a numeric component has a leading zero.1.0.foo
- uses a non-numeric components where one is expected.1.0.0foo
- metadata is not separated using a legal character like,+
or-
.1.0.0+foo_123
- contains metadata with an illegal character (_
). Legal characters for metadata includea-z
,A-Z
,0-9
,-
, and.
(dot).
sourcepub fn increment_patch(&mut self)
pub fn increment_patch(&mut self)
Increments the patch number for this Version (Must be mutable)
sourcepub fn increment_minor(&mut self)
pub fn increment_minor(&mut self)
Increments the minor version number for this Version (Must be mutable)
As instructed by section 7 of the spec, the patch number is reset to 0.
sourcepub fn increment_major(&mut self)
pub fn increment_major(&mut self)
Increments the major version number for this Version (Must be mutable)
As instructed by section 8 of the spec, the minor and patch numbers are reset to 0
sourcepub fn is_prerelease(&self) -> bool
pub fn is_prerelease(&self) -> bool
Checks to see if the current Version is in pre-release status
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Version
impl<'de> Deserialize<'de> for Version
sourcefn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl FromStr for Version
impl FromStr for Version
type Err = SemVerError
type Err = SemVerError
The associated error which can be returned from parsing.
sourceimpl Ord for Version
impl Ord for Version
sourceimpl PartialOrd<Version> for Version
impl PartialOrd<Version> for Version
sourcefn partial_cmp(&self, other: &Version) -> Option<Ordering>
fn partial_cmp(&self, other: &Version) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Eq for Version
impl StructuralEq for Version
Auto Trait Implementations
impl RefUnwindSafe for Version
impl Send for Version
impl Sync for Version
impl Unpin for Version
impl UnwindSafe for Version
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more