Skip to content

Commit

Permalink
feat: implement Display and AsRef for MappedRef (#261)
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Jul 11, 2023
1 parent dcc97f8 commit 079faeb
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/mapref/one.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,20 @@ 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: AsRef<TDeref>, TDeref: ?Sized> AsRef<TDeref>
for MappedRef<'a, K, V, T>
{
fn as_ref(&self) -> &TDeref {
self.value().as_ref()
}
}

pub struct MappedRefMut<'a, K, V, T, S = RandomState> {
_guard: RwLockWriteGuard<'a, HashMap<K, V, S>>,
k: *const K,
Expand Down

0 comments on commit 079faeb

Please sign in to comment.