Struct sile::types::semver::Semver

source ·
pub struct Semver { /* private fields */ }

Implementations§

source§

impl Semver

source

pub fn new(version: &str) -> Result<Self>

Methods from Deref<Target = Version>§

source

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§

source§

impl Clone for Semver

source§

fn clone(&self) -> Semver

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Semver

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Deref for Semver

source§

type Target = Version

The resulting type after dereferencing.
source§

fn deref(&self) -> &Version

Dereferences the value.
source§

impl FromLua for Semver

source§

fn from_lua(value: LuaValue, _: &Lua) -> LuaResult<Self>

Performs the conversion.
source§

impl UserData for Semver

source§

fn add_fields<F: LuaUserDataFields<Self>>(fields: &mut F)

Adds custom fields specific to this userdata.
source§

fn add_methods<M: LuaUserDataMethods<Self>>(methods: &mut M)

Adds custom methods and operators specific to this userdata.
§

fn register(registry: &mut UserDataRegistry<Self>)

Registers this type for use in Lua. Read more

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromLuaMulti for T
where T: FromLua,

§

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, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 T
where T: UserData + MaybeSend + 'static,

§

fn into_lua(self, lua: &Lua) -> Result<Value, Error>

Performs the conversion.
§

impl<T> IntoLuaMulti for T
where T: IntoLua,

§

fn into_lua_multi(self, lua: &Lua) -> Result<MultiValue, Error>

Performs the conversion.
§

unsafe fn push_into_stack_multi(self, lua: &RawLua) -> Result<i32, Error>

source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> MaybeSend for T