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:
Kévin Commaille 2023-02-06 17:33:00 +01:00 committed by Kévin Commaille
parent db6acae8a8
commit ad86f4603a
2 changed files with 6 additions and 2 deletions

View File

@ -1,5 +1,9 @@
# [unreleased]
Improvements:
- Derive `Hash` for `ReceiptType` and `ReceiptThread`
# 0.11.1
Improvements:

View File

@ -59,7 +59,7 @@ pub type Receipts = BTreeMap<ReceiptType, UserReceipts>;
/// The type of receipt.
#[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]
pub enum ReceiptType {
/// A [public read receipt].
@ -132,7 +132,7 @@ impl Receipt {
/// 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
#[derive(Clone, Debug, Default, PartialEq, Eq)]
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum ReceiptThread {
/// The receipt applies to the timeline, regardless of threads.