mirror of
https://github.com/chatmail/core.git
synced 2026-04-21 15:36:30 +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")]
|
||||
#[allow(dead_code)]
|
||||
pub enum HeaderDef {
|
||||
@@ -43,8 +45,8 @@ pub enum HeaderDef {
|
||||
|
||||
impl HeaderDef {
|
||||
/// Returns the corresponding Event id.
|
||||
pub fn get_headername(&self) -> String {
|
||||
self.to_string()
|
||||
pub fn get_headername(&self) -> &'static str {
|
||||
self.as_static()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,8 +57,8 @@ mod tests {
|
||||
#[test]
|
||||
/// Test that kebab_case serialization works as expected
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user