Avoid string copy for Key: From<String> implementation (#3858)

The macro uses `to_string().as_str()` which copies the string. Avoid
that by using `as_str()` directly on the source.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
flumm 2025-05-13 14:06:17 +02:00 committed by GitHub
parent a86c4f847f
commit 433a0f2eca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -41,6 +41,12 @@ impl From<&'_ str> for Key {
}
}
impl From<String> for Key {
fn from(key: String) -> Self {
Self::from(key.as_str())
}
}
impl ImplicitClone for Key {}
macro_rules! key_impl_from_to_string {
@ -53,7 +59,6 @@ macro_rules! key_impl_from_to_string {
};
}
key_impl_from_to_string!(String);
key_impl_from_to_string!(char);
key_impl_from_to_string!(u8);
key_impl_from_to_string!(u16);