From f033c6889e0071b29e75c551586e8e5da1b556a3 Mon Sep 17 00:00:00 2001 From: Rutger Broekhoff Date: Fri, 26 Jan 2024 12:34:47 +0100 Subject: Use serde_json::json! instead of manually generating JSON --- common/src/lib.rs | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'common/src') diff --git a/common/src/lib.rs b/common/src/lib.rs index 0a538a5..c26150d 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -254,27 +254,6 @@ impl> fmt::Display for HexFmt { } } -pub struct EscJsonFmt<'a>(pub &'a str); - -impl<'a> fmt::Display for EscJsonFmt<'a> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let EscJsonFmt(buf) = self; - for c in buf.chars() { - match c { - '"' => f.write_str("\\\"")?, // quote - '\\' => f.write_str("\\\\")?, // backslash - '\x08' => f.write_str("\\b")?, // backspace - '\x0C' => f.write_str("\\f")?, // form feed - '\n' => f.write_str("\\n")?, // line feed - '\r' => f.write_str("\\r")?, // carriage return - '\t' => f.write_str("\\t")?, // horizontal tab - _ => f.write_char(c)?, - }; - } - Ok(()) - } -} - #[derive(Debug, Copy, Clone)] pub struct Digest { inner: [u8; N], -- cgit v1.2.3