Implement Deref<Target=str> for Key
//! This module contains the implementation yew's virtual nodes' keys.
+use std::ops::Deref;
use std::rc::Rc;
/// Represents the (optional) key of Yew's virtual nodes.
@@ -29,6 +30,15 @@ impl From<Rc<String>> for Key {
}
}
+impl Deref for Key {
+ type Target = str;
+
+ #[inline]
+ fn deref(&self) -> &str {
+ self.key.as_ref()
+ }
+}
+
macro_rules! key_impl_from_to_string {
($type:ty) => {
impl From<$type> for Key {
