Struct nextsv_lib::Semantic
source · [−]pub struct Semantic { /* private fields */ }Expand description
The Semantic data structure represents a semantic version number.
TODO: Implement support for pre-release and build
Implementations
sourceimpl Semantic
impl Semantic
sourcepub fn parse(tag: &str, version_prefix: &str) -> Result<Self, Error>
pub fn parse(tag: &str, version_prefix: &str) -> Result<Self, Error>
Parse a tag and return a struct String format expect: <version_prefix>x.y.z
Fields
tag - the tag proposed as a semantic version tag version_prefix - any string before the semantic version number
Example
Parse a tag into a semantic version number where “v” is used to identify tags representing semantic version numbers.
use nextsv_lib::Semantic;
let tag = "v0.2.3";
let semantic_version = Semantic::parse(tag, "v")?;
assert_eq!(0, semantic_version.major());
assert_eq!(2, semantic_version.minor());
assert_eq!(3, semantic_version.patch());
to identify tags with semantic version numbers the tag name can be parsed
sourcepub fn breaking_increment(&mut self) -> &mut Self
pub fn breaking_increment(&mut self) -> &mut Self
Increment the version based on a breaking change When the major number is 0 increment the minor number else increment the major number
sourcepub fn increment_patch(&mut self) -> &mut Self
pub fn increment_patch(&mut self) -> &mut Self
Increment the patch component of the version number by 1
sourcepub fn increment_minor(&mut self) -> &mut Self
pub fn increment_minor(&mut self) -> &mut Self
Increment the minor component of the version number by 1
sourcepub fn increment_major(&mut self) -> &mut Self
pub fn increment_major(&mut self) -> &mut Self
Increment the major component of the version number by 1
sourcepub fn first_production(&mut self) -> Result<&mut Self, Error>
pub fn first_production(&mut self) -> Result<&mut Self, Error>
Set the first production release version
pub fn major(&self) -> usize
pub fn minor(&self) -> usize
pub fn patch(&self) -> usize
Trait Implementations
sourceimpl Ord for Semantic
impl Ord for Semantic
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialOrd<Semantic> for Semantic
impl PartialOrd<Semantic> for Semantic
sourcefn partial_cmp(&self, other: &Semantic) -> Option<Ordering>
fn partial_cmp(&self, other: &Semantic) -> 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 Semantic
impl StructuralEq for Semantic
impl StructuralPartialEq for Semantic
Auto Trait Implementations
impl RefUnwindSafe for Semantic
impl Send for Semantic
impl Sync for Semantic
impl Unpin for Semantic
impl UnwindSafe for Semantic
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more