pub struct SemVer {
pub major: u32,
pub minor: u32,
pub patch: u32,
}Expand description
The major.minor.patch version object, serialized as a nested mapping to
match r2modman’s VersionNumber.
Versions are totally ordered by major, then minor, then patch, each compared
as a number, and one version is newer than another when it compares greater.
A component parse fills in as 0 orders as 0, so 1.2
equals 1.2.0.
use thunderstore_engine::profile::modlist::SemVer;
assert!(SemVer::parse("1.0.10") > SemVer::parse("1.0.9"));
assert!(SemVer::parse("1.2.1") > SemVer::parse("1.2"));Fields§
§major: u32The major component, or 0 if the source string had none.
minor: u32The minor component, or 0 if the source string had none.
patch: u32The patch component, or 0 if the source string had none. A prerelease
suffix is discarded, so 1.2.3-beta parses to a patch of 3.
Implementations§
Source§impl SemVer
impl SemVer
Sourcepub fn parse(s: &str) -> SemVer
pub fn parse(s: &str) -> SemVer
Parses the first three dot-separated integer components of s; a missing or
non-numeric component becomes 0 (so "1.2" -> 1.2.0, "1.2.3-beta" ->
1.2.3).
Never fails and never panics: an unparseable or overflowing component
degrades to 0 rather than rejecting a mods.yml r2modman itself accepts.
§Examples
use thunderstore_engine::profile::modlist::SemVer;
assert_eq!(SemVer::parse("1.2.3").to_string(), "1.2.3");
assert_eq!(SemVer::parse("1.2").to_string(), "1.2.0");
assert_eq!(SemVer::parse("1.2.3-beta").to_string(), "1.2.3");
assert_eq!(SemVer::parse("not-a-version").to_string(), "0.0.0");Trait Implementations§
impl Copy for SemVer
Source§impl<'de> Deserialize<'de> for SemVer
impl<'de> Deserialize<'de> for SemVer
Source§fn 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>,
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,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for SemVer
impl PartialOrd for SemVer
impl StructuralPartialEq for SemVer
Auto Trait Implementations§
impl Forget for SemVer
impl Freeze for SemVer
impl Move 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
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
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<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.