Add PartialOrd and Ord implementations for RoomVersionId
This commit is contained in:
parent
f6f0b58a1c
commit
1093c2f84d
@ -13,6 +13,7 @@ Improvements:
|
||||
|
||||
* Update the internal representation of identifiers to be more compact
|
||||
* Add `RoomVersionId::version_6` and `RoomVersionId::is_version_6`
|
||||
* Add `PartialOrd` and `Ord` implementations for `RoomVersionId`
|
||||
|
||||
# 0.16.1
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
//! Matrix room version identifiers.
|
||||
|
||||
use std::{
|
||||
cmp::Ordering,
|
||||
convert::TryFrom,
|
||||
fmt::{self, Display, Formatter},
|
||||
};
|
||||
@ -23,7 +24,7 @@ const MAX_CODE_POINTS: usize = 32;
|
||||
/// # use ruma_identifiers::RoomVersionId;
|
||||
/// assert_eq!(RoomVersionId::try_from("1").unwrap().as_ref(), "1");
|
||||
/// ```
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub struct RoomVersionId(InnerRoomVersionId);
|
||||
|
||||
/// Possibile values for room version, distinguishing between official Matrix versions and custom
|
||||
@ -166,6 +167,18 @@ impl Display for RoomVersionId {
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialOrd for RoomVersionId {
|
||||
fn partial_cmp(&self, other: &RoomVersionId) -> Option<Ordering> {
|
||||
self.as_ref().partial_cmp(other.as_ref())
|
||||
}
|
||||
}
|
||||
|
||||
impl Ord for RoomVersionId {
|
||||
fn cmp(&self, other: &Self) -> Ordering {
|
||||
self.as_ref().cmp(other.as_ref())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
impl Serialize for RoomVersionId {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
|
Loading…
x
Reference in New Issue
Block a user