pub struct SemanticVersion {
pub major: i64,
pub minor: i64,
pub patch: i64,
pub pre_release_tag: PreReleaseTag,
pub build_metadata: BuildMetaData,
}Expand description
A complete semantic version.
Fields§
§major: i64§minor: i64§patch: i64§pre_release_tag: PreReleaseTag§build_metadata: BuildMetaDataImplementations§
Source§impl SemanticVersion
impl SemanticVersion
pub fn new(major: i64, minor: i64, patch: i64) -> Self
Sourcepub fn major_minor_patch(&self) -> String
pub fn major_minor_patch(&self) -> String
Returns only Major.Minor.Patch.
Sourcepub fn parse(input: &str, tag_prefix: &str) -> Option<Self>
pub fn parse(input: &str, tag_prefix: &str) -> Option<Self>
Parse a version string (Loose). Strips the leading prefix matched by tag_prefix before parsing.
Examples: v1.2.3-beta.4, 1.2, 1.
Sourcepub fn parse_with(input: &str, tag_prefix: &str, strict: bool) -> Option<Self>
pub fn parse_with(input: &str, tag_prefix: &str, strict: bool) -> Option<Self>
Parse a version string. When strict is true, all three components (Major.Minor.Patch) are
required, as in SemVer 2.0 (mirrors the original SemanticVersionFormat.Strict). Loose allows partial versions.
Sourcepub fn cmp_core(&self, other: &Self) -> Ordering
pub fn cmp_core(&self, other: &Self) -> Ordering
Compare only the core version (ignoring pre-release).
Sourcepub fn increment(
&self,
field: VersionField,
label: Option<&str>,
force: bool,
) -> Self
pub fn increment( &self, field: VersionField, label: Option<&str>, force: bool, ) -> Self
Increment the specified field and apply the label. Mirrors the original SemanticVersion.Increment.
- If a pre-release already exists and
forceis false, the core is not bumped; the pre-release is kept. labelofSome("")(empty string) creates a name-less promoted pre-release that still exposes its number (e.g.0.0.1-1).Nonemeans no label is applied.
Trait Implementations§
Source§impl Clone for SemanticVersion
impl Clone for SemanticVersion
Source§fn clone(&self) -> SemanticVersion
fn clone(&self) -> SemanticVersion
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SemanticVersion
impl Debug for SemanticVersion
Source§impl Default for SemanticVersion
impl Default for SemanticVersion
Source§fn default() -> SemanticVersion
fn default() -> SemanticVersion
Returns the “default value” for a type. Read more
Source§impl Display for SemanticVersion
impl Display for SemanticVersion
impl Eq for SemanticVersion
Source§impl Ord for SemanticVersion
impl Ord for SemanticVersion
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for SemanticVersion
impl PartialEq for SemanticVersion
Source§fn eq(&self, other: &SemanticVersion) -> bool
fn eq(&self, other: &SemanticVersion) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialOrd for SemanticVersion
impl PartialOrd for SemanticVersion
impl StructuralPartialEq for SemanticVersion
Auto Trait Implementations§
impl Freeze for SemanticVersion
impl RefUnwindSafe for SemanticVersion
impl Send for SemanticVersion
impl Sync for SemanticVersion
impl Unpin for SemanticVersion
impl UnsafeUnpin for SemanticVersion
impl UnwindSafe for SemanticVersion
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
Fallible version of
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a
CompactString. Read more