diff --git a/src/util/dictionary/immutable.rs b/src/util/dictionary/immutable.rs index 058547f..e6c612a 100644 --- a/src/util/dictionary/immutable.rs +++ b/src/util/dictionary/immutable.rs @@ -1,5 +1,6 @@ use std::ffi::{CStr, CString}; use std::marker::PhantomData; +use std::fmt; use std::ptr; use std::str::from_utf8_unchecked; @@ -58,3 +59,9 @@ impl<'a> IntoIterator for &'a Ref<'a> { self.iter() } } + +impl<'a> fmt::Debug for Ref<'a> { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_map().entries(self.iter()).finish() + } +} diff --git a/src/util/dictionary/mutable.rs b/src/util/dictionary/mutable.rs index 7e345fb..6fe1cc0 100644 --- a/src/util/dictionary/mutable.rs +++ b/src/util/dictionary/mutable.rs @@ -1,7 +1,7 @@ use std::ffi::CString; use std::marker::PhantomData; use std::ops::Deref; - +use std::fmt; use super::immutable; use ffi::*; @@ -50,3 +50,9 @@ impl<'a> Deref for Ref<'a> { &self.imm } } + +impl<'a> fmt::Debug for Ref<'a> { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + self.imm.fmt(fmt) + } +} diff --git a/src/util/dictionary/owned.rs b/src/util/dictionary/owned.rs index 00d06ed..7818861 100644 --- a/src/util/dictionary/owned.rs +++ b/src/util/dictionary/owned.rs @@ -1,7 +1,7 @@ use std::iter::FromIterator; use std::ops::{Deref, DerefMut}; use std::ptr; - +use std::fmt; use super::mutable; use ffi::*; @@ -126,3 +126,9 @@ impl<'a> Drop for Owned<'a> { } } } + +impl<'a> fmt::Debug for Owned<'a> { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + self.inner.fmt(fmt) + } +}