mirror of
https://github.com/yewstack/yew.git
synced 2025-12-08 21:26:25 +00:00
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:
parent
a86c4f847f
commit
433a0f2eca
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user