From babd90c28881f6a03ca549ae2db12144b05dba48 Mon Sep 17 00:00:00 2001 From: Danni Moiseyev Date: Thu, 8 Sep 2022 07:12:52 +0300 Subject: [PATCH] Derive Clone and add Deref trait to InfoDict (#661) --- redis/src/types.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/redis/src/types.rs b/redis/src/types.rs index 395764e6f..a580a167d 100644 --- a/redis/src/types.rs +++ b/redis/src/types.rs @@ -13,6 +13,7 @@ use std::string::FromUtf8Error; pub(crate) use ahash::{AHashMap as HashMap, AHashSet as HashSet}; #[cfg(not(feature = "ahash"))] pub(crate) use std::collections::{HashMap, HashSet}; +use std::ops::Deref; macro_rules! invalid_type_error { ($v:expr, $det:expr) => {{ @@ -578,7 +579,7 @@ pub type RedisResult = Result; pub type RedisFuture<'a, T> = futures_util::future::BoxFuture<'a, RedisResult>; /// An info dictionary type. -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct InfoDict { map: HashMap, } @@ -648,6 +649,14 @@ impl InfoDict { } } +impl Deref for InfoDict { + type Target = HashMap; + + fn deref(&self) -> &Self::Target { + &self.map + } +} + /// Abstraction trait for redis command abstractions. pub trait RedisWrite { /// Accepts a serialized redis command.