From aa5f2c90caf9f42cfc6061acbda1e0474de2d0d3 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sun, 24 Sep 2023 00:42:22 -0700 Subject: [PATCH] fix: support alternative states for AsRef/Display of MappedRef --- src/mapref/one.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/mapref/one.rs b/src/mapref/one.rs index fd385309..dff19c1d 100644 --- a/src/mapref/one.rs +++ b/src/mapref/one.rs @@ -3,7 +3,7 @@ use crate::HashMap; use core::hash::{BuildHasher, Hash}; use core::ops::{Deref, DerefMut}; use std::collections::hash_map::RandomState; -use std::fmt::{Debug, Formatter}; +use std::fmt::{Debug, Display, Formatter}; pub struct Ref<'a, K, V, S = RandomState> { _guard: RwLockReadGuard<'a, HashMap>, @@ -241,14 +241,14 @@ impl<'a, K: Eq + Hash, V, T, S: BuildHasher> Deref for MappedRef<'a, K, V, T, S> } } -impl<'a, K: Eq + Hash, V, T: std::fmt::Display> std::fmt::Display for MappedRef<'a, K, V, T> { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - std::fmt::Display::fmt(self.value(), f) +impl<'a, K: Eq + Hash, V, T: Display, S: BuildHasher> Display for MappedRef<'a, K, V, T, S> { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + Display::fmt(self.value(), f) } } -impl<'a, K: Eq + Hash, V, T: AsRef, TDeref: ?Sized> AsRef - for MappedRef<'a, K, V, T> +impl<'a, K: Eq + Hash, V, T: AsRef, TDeref: ?Sized, S: BuildHasher> AsRef + for MappedRef<'a, K, V, T, S> { fn as_ref(&self) -> &TDeref { self.value().as_ref()