Add Debug for dictionary

This commit is contained in:
Kornel Lesiński 2020-06-19 18:46:21 +01:00 committed by Zhiming Wang
parent b31b5507fb
commit 53570d13d7
No known key found for this signature in database
GPG Key ID: 5B58F95EC95965D8
3 changed files with 21 additions and 0 deletions

View File

@ -1,4 +1,5 @@
use std::ffi::{CStr, CString}; use std::ffi::{CStr, CString};
use std::fmt;
use std::marker::PhantomData; use std::marker::PhantomData;
use std::ptr; use std::ptr;
use std::str::from_utf8_unchecked; use std::str::from_utf8_unchecked;
@ -58,3 +59,9 @@ impl<'a> IntoIterator for &'a Ref<'a> {
self.iter() 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()
}
}

View File

@ -1,4 +1,5 @@
use std::ffi::CString; use std::ffi::CString;
use std::fmt;
use std::marker::PhantomData; use std::marker::PhantomData;
use std::ops::Deref; use std::ops::Deref;
@ -50,3 +51,9 @@ impl<'a> Deref for Ref<'a> {
&self.imm &self.imm
} }
} }
impl<'a> fmt::Debug for Ref<'a> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
self.imm.fmt(fmt)
}
}

View File

@ -1,3 +1,4 @@
use std::fmt;
use std::iter::FromIterator; use std::iter::FromIterator;
use std::ops::{Deref, DerefMut}; use std::ops::{Deref, DerefMut};
use std::ptr; use std::ptr;
@ -126,3 +127,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)
}
}