Skip to content

Commit

Permalink
Added Debug and Display to ByteBuf
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuri6037 committed Nov 21, 2023
1 parent bf0051d commit 34e45a8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bytesutil"
version = "0.2.0"
version = "0.3.0"
authors = ["Yuri Edward <[email protected]>"]
edition = "2021"
description = "Yet another byte utility for Rust"
Expand Down
14 changes: 14 additions & 0 deletions src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

use core::fmt::{Debug, Display};

use crate::{ReadBytes, WriteBytes};

/// A java-like wrapper over a buffer of bytes.
Expand Down Expand Up @@ -96,6 +98,18 @@ impl<T: PartialEq> PartialEq for ByteBuf<T> {

impl<T: Eq> Eq for ByteBuf<T> {}

impl<T: Debug> Debug for ByteBuf<T> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
self.inner.fmt(f)
}
}

impl<T: Display> Display for ByteBuf<T> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
self.inner.fmt(f)
}
}

/// A shortcut to create a stack allocated fixed size [ByteBuf](ByteBuf)
pub type StaticByteBuf<const N: usize> = ByteBuf<[u8; N]>;

Expand Down

0 comments on commit 34e45a8

Please sign in to comment.