pub struct RpcApiVersion(/* private fields */);
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§
Source§impl Clone for RpcApiVersion
impl Clone for RpcApiVersion
Source§fn clone(&self) -> RpcApiVersion
fn clone(&self) -> RpcApiVersion
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for RpcApiVersion
impl Debug for RpcApiVersion
Source§impl Default for RpcApiVersion
impl Default for RpcApiVersion
Source§fn default() -> RpcApiVersion
fn default() -> RpcApiVersion
Returns the “default value” for a type. Read more
Source§impl Deref for RpcApiVersion
impl Deref for RpcApiVersion
Source§impl<'de> Deserialize<'de> for RpcApiVersion
impl<'de> Deserialize<'de> for RpcApiVersion
Source§fn deserialize<D>(
deserializer: D,
) -> Result<RpcApiVersion, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<RpcApiVersion, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for RpcApiVersion
impl PartialEq for RpcApiVersion
Source§impl Serialize for RpcApiVersion
impl Serialize for RpcApiVersion
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Eq for RpcApiVersion
impl StructuralPartialEq for RpcApiVersion
Auto Trait Implementations§
impl Freeze for RpcApiVersion
impl RefUnwindSafe for RpcApiVersion
impl Send for RpcApiVersion
impl Sync for RpcApiVersion
impl Unpin for RpcApiVersion
impl UnwindSafe for RpcApiVersion
Blanket Implementations§
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
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<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§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
Compare self to
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>
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