push: Implement AsRef<str> for PredefinedRuleId

This commit is contained in:
Kévin Commaille 2023-12-01 12:50:32 +01:00 committed by Kévin Commaille
parent df1a63909a
commit ba75b09a45
2 changed files with 18 additions and 0 deletions

View File

@ -11,6 +11,7 @@ Improvements:
- Stabilize support for `.m.rule.suppress_edits` push rule (MSC3958 / Matrix 1.9)
- Add `MatrixVersion::V1_9`
- Point links to the Matrix 1.9 specification
- Implement `as_str()` and `AsRef<str>` for `push::PredefinedRuleId`
# 0.12.1

View File

@ -555,6 +555,23 @@ pub enum PredefinedRuleId {
Content(PredefinedContentRuleId),
}
impl PredefinedRuleId {
/// Creates a string slice from this `PredefinedRuleId`.
pub fn as_str(&self) -> &str {
match self {
Self::Override(id) => id.as_str(),
Self::Underride(id) => id.as_str(),
Self::Content(id) => id.as_str(),
}
}
}
impl AsRef<str> for PredefinedRuleId {
fn as_ref(&self) -> &str {
self.as_str()
}
}
/// The rule IDs of the predefined override server push rules.
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, StringEnum)]