pub struct SemVer {
pub major: u32,
pub minor: u32,
pub patch: u32,
pub pre: Option<String>,
}Expand description
A parsed semantic version (major.minor.patch[-pre]).
Fields§
§major: u32Major version component.
minor: u32Minor version component.
patch: u32Patch version component.
pre: Option<String>Optional pre-release identifier (e.g. "alpha.1").
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 release version (no pre-release).
Sourcepub fn with_pre(
major: u32,
minor: u32,
patch: u32,
pre: impl Into<String>,
) -> Self
pub fn with_pre( major: u32, minor: u32, patch: u32, pre: impl Into<String>, ) -> Self
Construct a pre-release version.
Sourcepub fn parse(s: &str) -> Result<Self, ResolveError>
pub fn parse(s: &str) -> Result<Self, ResolveError>
Parse a semver string such as "1.2.3" or "1.0.0-beta.2".
§Errors
Returns a ResolveError::NotFound-wrapping string on parse failure.
Sourcepub fn is_compatible_with(&self, required: &SemVer) -> bool
pub fn is_compatible_with(&self, required: &SemVer) -> bool
Semver compatibility check: same major, self >= required.
This is the ^ (caret) / “compatible” definition.
Trait Implementations§
Source§impl Ord for SemVer
impl Ord for SemVer
Source§impl PartialOrd for SemVer
impl PartialOrd for SemVer
impl Eq for SemVer
impl StructuralPartialEq for SemVer
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§
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<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 more