pub struct SemVer {
pub major: u32,
pub minor: u32,
pub patch: u32,
pub pre_release: Option<String>,
pub build_metadata: Option<String>,
}Expand description
A Semantic Versioning 2.0 version triple plus optional pre-release and build-metadata labels.
Ordering and equality are based solely on (major, minor, patch).
Fields§
§major: u32Major version — breaking changes.
minor: u32Minor version — backward-compatible new features.
patch: u32Patch version — backward-compatible bug fixes.
pre_release: Option<String>Optional pre-release identifier (e.g. "alpha", "beta.1").
build_metadata: Option<String>Optional build metadata (e.g. "build.1", "20240101").
Implementations§
Source§impl SemVer
impl SemVer
Sourcepub fn new(major: u32, minor: u32, patch: u32) -> Self
pub fn new(major: u32, minor: u32, patch: u32) -> Self
Construct a new version without pre-release or build metadata.
Sourcepub fn parse(s: &str) -> Result<SemVer, SemVerError>
pub fn parse(s: &str) -> Result<SemVer, SemVerError>
Parse a SemVer string such as "1.2.3", "1.2.3-alpha",
"1.2.3+build.1", or "1.2.3-alpha+build".
Sourcepub fn bump_major(&self) -> SemVer
pub fn bump_major(&self) -> SemVer
Increment the major version and zero out minor and patch. Clears pre-release and build metadata.
Sourcepub fn bump_minor(&self) -> SemVer
pub fn bump_minor(&self) -> SemVer
Increment the minor version and zero out patch. Clears pre-release and build metadata.
Sourcepub fn bump_patch(&self) -> SemVer
pub fn bump_patch(&self) -> SemVer
Increment the patch version. Clears pre-release and build metadata.
Sourcepub fn is_compatible_with(&self, other: &SemVer) -> bool
pub fn is_compatible_with(&self, other: &SemVer) -> bool
Returns true when self is compatible with other:
same major version AND self >= other.
Trait Implementations§
impl Eq for SemVer
Source§impl Ord for SemVer
impl Ord for SemVer
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Auto Trait Implementations§
impl Freeze for SemVer
impl RefUnwindSafe for SemVer
impl Send for SemVer
impl Sync for SemVer
impl Unpin for SemVer
impl UnsafeUnpin for SemVer
impl UnwindSafe for SemVer
Blanket Implementations§
impl<T> Allocation for T
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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
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>
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>
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> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.