feat: impl TryFrom<String> for NonSpecialMessage that avoids cloning
This commit is contained in:
@@ -70,6 +70,19 @@ impl FromStr for NonSpecialMessage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl TryFrom<String> for NonSpecialMessage {
|
||||||
|
type Error = WasSpecialMessage;
|
||||||
|
|
||||||
|
fn try_from(s: String) -> Result<Self, Self::Error> {
|
||||||
|
match SpecialMessage::from_str(&s) {
|
||||||
|
Ok(special_message) => Err(WasSpecialMessage {
|
||||||
|
got: special_message,
|
||||||
|
}),
|
||||||
|
Err(_e) => Ok(NonSpecialMessage(s)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// How much of a notification is visible on the lock screen
|
/// How much of a notification is visible on the lock screen
|
||||||
#[derive(Debug, Clone, Default, EnumString, strum::Display)]
|
#[derive(Debug, Clone, Default, EnumString, strum::Display)]
|
||||||
#[strum(serialize_all = "snake_case")]
|
#[strum(serialize_all = "snake_case")]
|
||||||
|
|||||||
Reference in New Issue
Block a user