From 0568e76406fc4869152671a255c5e1efca6611a6 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 13 Aug 2018 15:44:51 +0300 Subject: [PATCH] smol debug --- crates/smol_str/src/lib.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/crates/smol_str/src/lib.rs b/crates/smol_str/src/lib.rs index 4d5fef5932..41c3a39ef8 100644 --- a/crates/smol_str/src/lib.rs +++ b/crates/smol_str/src/lib.rs @@ -1,6 +1,6 @@ -use std::{sync::Arc, ops::Deref}; +use std::{sync::Arc, ops::Deref, fmt}; -#[derive(Clone, Debug)] +#[derive(Clone)] pub struct SmolStr(Repr); impl SmolStr { @@ -49,6 +49,18 @@ impl<'a> PartialEq for &'a str { } } +impl fmt::Debug for SmolStr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Debug::fmt(self.as_str(), f) + } +} + +impl fmt::Display for SmolStr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(self.as_str(), f) + } +} + const INLINE_CAP: usize = 22; const WS_TAG: u8 = (INLINE_CAP + 1) as u8;