events: Derive Hash for ReceiptType and ReceiptThread
Since uniqueness of receipts is determined per type and per thread it's common to use them as keys of a map.
This commit is contained in:
parent
db6acae8a8
commit
ad86f4603a
@ -1,5 +1,9 @@
|
|||||||
# [unreleased]
|
# [unreleased]
|
||||||
|
|
||||||
|
Improvements:
|
||||||
|
|
||||||
|
- Derive `Hash` for `ReceiptType` and `ReceiptThread`
|
||||||
|
|
||||||
# 0.11.1
|
# 0.11.1
|
||||||
|
|
||||||
Improvements:
|
Improvements:
|
||||||
|
@ -59,7 +59,7 @@ pub type Receipts = BTreeMap<ReceiptType, UserReceipts>;
|
|||||||
|
|
||||||
/// The type of receipt.
|
/// The type of receipt.
|
||||||
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
|
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
|
||||||
#[derive(Clone, PartialOrdAsRefStr, OrdAsRefStr, PartialEqAsRefStr, Eq, StringEnum)]
|
#[derive(Clone, PartialOrdAsRefStr, OrdAsRefStr, PartialEqAsRefStr, Eq, StringEnum, Hash)]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum ReceiptType {
|
pub enum ReceiptType {
|
||||||
/// A [public read receipt].
|
/// A [public read receipt].
|
||||||
@ -132,7 +132,7 @@ impl Receipt {
|
|||||||
/// representation, obtained through [`.as_str()`](Self::as_str()).
|
/// representation, obtained through [`.as_str()`](Self::as_str()).
|
||||||
///
|
///
|
||||||
/// [thread a receipt applies to]: https://spec.matrix.org/v1.4/client-server-api/#threaded-read-receipts
|
/// [thread a receipt applies to]: https://spec.matrix.org/v1.4/client-server-api/#threaded-read-receipts
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq)]
|
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum ReceiptThread {
|
pub enum ReceiptThread {
|
||||||
/// The receipt applies to the timeline, regardless of threads.
|
/// The receipt applies to the timeline, regardless of threads.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user