feat: impl Debug for dictionary

This commit is contained in:
Kornel
2020-12-09 02:01:35 +01:00
committed by GitHub
parent 4cbaed0a77
commit 905bfba588
3 changed files with 21 additions and 2 deletions
+7
View File
@@ -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()
}
}
+7 -1
View File
@@ -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)
}
}
+7 -1
View File
@@ -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)
}
}