pub struct Semver { /* private fields */ }
Implementations§
Methods from Deref<Target = Version>§
sourcepub fn cmp_precedence(&self, other: &Version) -> Ordering
pub fn cmp_precedence(&self, other: &Version) -> Ordering
Compare the major, minor, patch, and pre-release value of two versions, disregarding build metadata. Versions that differ only in build metadata are considered equal. This comparison is what the SemVer spec refers to as “precedence”.
§Example
use semver::Version;
let mut versions = [
"1.20.0+c144a98".parse::<Version>().unwrap(),
"1.20.0".parse().unwrap(),
"1.0.0".parse().unwrap(),
"1.0.0-alpha".parse().unwrap(),
"1.20.0+bc17664".parse().unwrap(),
];
// This is a stable sort, so it preserves the relative order of equal
// elements. The three 1.20.0 versions differ only in build metadata so
// they are not reordered relative to one another.
versions.sort_by(Version::cmp_precedence);
assert_eq!(versions, [
"1.0.0-alpha".parse().unwrap(),
"1.0.0".parse().unwrap(),
"1.20.0+c144a98".parse().unwrap(),
"1.20.0".parse().unwrap(),
"1.20.0+bc17664".parse().unwrap(),
]);
// Totally order the versions, including comparing the build metadata.
versions.sort();
assert_eq!(versions, [
"1.0.0-alpha".parse().unwrap(),
"1.0.0".parse().unwrap(),
"1.20.0".parse().unwrap(),
"1.20.0+bc17664".parse().unwrap(),
"1.20.0+c144a98".parse().unwrap(),
]);
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Semver
impl RefUnwindSafe for Semver
impl Send for Semver
impl Sync for Semver
impl Unpin 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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<T> FromLuaMulti for Twhere
T: FromLua,
impl<T> FromLuaMulti for Twhere
T: FromLua,
§fn from_lua_multi(values: MultiValue, lua: &Lua) -> Result<T, Error>
fn from_lua_multi(values: MultiValue, lua: &Lua) -> Result<T, Error>
Performs the conversion. Read more
fn from_lua_args( args: MultiValue, i: usize, to: Option<&str>, lua: &Lua, ) -> Result<T, Error>
unsafe fn from_stack_multi(nvals: i32, lua: &RawLua) -> Result<T, Error>
unsafe fn from_stack_args( nargs: i32, i: usize, to: Option<&str>, lua: &RawLua, ) -> Result<T, Error>
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§impl<T> IntoLua for Twhere
T: UserData + MaybeSend + 'static,
impl<T> IntoLua for Twhere
T: UserData + MaybeSend + 'static,
§impl<T> IntoLuaMulti for Twhere
T: IntoLua,
impl<T> IntoLuaMulti for Twhere
T: IntoLua,
§fn into_lua_multi(self, lua: &Lua) -> Result<MultiValue, Error>
fn into_lua_multi(self, lua: &Lua) -> Result<MultiValue, Error>
Performs the conversion.