mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 17:36:29 +03:00
Return &'static str from HeaderDef.get_headername()
This commit is contained in:
committed by
holger krekel
parent
df252c4704
commit
b4573e341f
@@ -1,4 +1,6 @@
|
|||||||
#[derive(Debug, Display, Clone, PartialEq, Eq, EnumVariantNames)]
|
use crate::strum::AsStaticRef;
|
||||||
|
|
||||||
|
#[derive(Debug, Display, Clone, PartialEq, Eq, EnumVariantNames, AsStaticStr)]
|
||||||
#[strum(serialize_all = "kebab_case")]
|
#[strum(serialize_all = "kebab_case")]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub enum HeaderDef {
|
pub enum HeaderDef {
|
||||||
@@ -43,8 +45,8 @@ pub enum HeaderDef {
|
|||||||
|
|
||||||
impl HeaderDef {
|
impl HeaderDef {
|
||||||
/// Returns the corresponding Event id.
|
/// Returns the corresponding Event id.
|
||||||
pub fn get_headername(&self) -> String {
|
pub fn get_headername(&self) -> &'static str {
|
||||||
self.to_string()
|
self.as_static()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,8 +57,8 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
/// Test that kebab_case serialization works as expected
|
/// Test that kebab_case serialization works as expected
|
||||||
fn kebab_test() {
|
fn kebab_test() {
|
||||||
assert_eq!(HeaderDef::From_.to_string(), "from");
|
assert_eq!(HeaderDef::From_.get_headername(), "from");
|
||||||
|
|
||||||
assert_eq!(HeaderDef::_TestHeader.to_string(), "test-header");
|
assert_eq!(HeaderDef::_TestHeader.get_headername(), "test-header");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -402,7 +402,7 @@ impl MimeMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get(&self, headerdef: HeaderDef) -> Option<&String> {
|
pub fn get(&self, headerdef: HeaderDef) -> Option<&String> {
|
||||||
self.header.get(&headerdef.get_headername())
|
self.header.get(headerdef.get_headername())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_first_addr(&self, context: &Context, headerdef: HeaderDef) -> Option<MailAddr> {
|
fn parse_first_addr(&self, context: &Context, headerdef: HeaderDef) -> Option<MailAddr> {
|
||||||
|
|||||||
Reference in New Issue
Block a user