Skip to content

Commit

Permalink
Merge pull request #163 from sval-rs/feat/debug-impls
Browse files Browse the repository at this point in the history
Add Debug impls to some types
  • Loading branch information
KodrAus committed Sep 21, 2023
2 parents b02bfe1 + f316393 commit f3b75d4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/data/binary.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{tags, Result, Stream, Value};
use crate::{tags, Result, Stream, Value, std::fmt};

/**
An adapter that streams a slice of 8bit unsigned integers as binary.
Expand Down Expand Up @@ -27,6 +27,12 @@ impl BinarySlice {
}
}

impl fmt::Debug for BinarySlice {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Debug::fmt(&self.0, f)
}
}

impl AsRef<[u8]> for BinarySlice {
#[inline(always)]
fn as_ref(&self) -> &[u8] {
Expand Down Expand Up @@ -74,6 +80,12 @@ impl<const N: usize> BinaryArray<N> {
}
}

impl<const N: usize> fmt::Debug for BinaryArray<N> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Debug::fmt(&self.0, f)
}
}

impl<const N: usize> AsRef<[u8; N]> for BinaryArray<N> {
#[inline(always)]
fn as_ref(&self) -> &[u8; N] {
Expand Down
8 changes: 7 additions & 1 deletion src/data/map.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{Result, Stream, Value};
use crate::{Result, Stream, Value, std::fmt};

/**
An adapter that streams a slice of key-value pairs as a map.
Expand All @@ -23,6 +23,12 @@ impl<K, V> MapSlice<K, V> {
}
}

impl<K: fmt::Debug, V: fmt::Debug> fmt::Debug for MapSlice<K, V> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Debug::fmt(&self.0, f)
}
}

impl<K, V> AsRef<[(K, V)]> for MapSlice<K, V> {
fn as_ref(&self) -> &[(K, V)] {
&self.0
Expand Down

0 comments on commit f3b75d4

Please sign in to comment.