aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorLibravatar Rutger Broekhoff2024-01-26 12:34:47 +0100
committerLibravatar Rutger Broekhoff2024-01-26 12:34:47 +0100
commitf033c6889e0071b29e75c551586e8e5da1b556a3 (patch)
tree7ab82ed0c11b6d4a1d45d3526015ecd631790be5 /common
parentf146743061ba8170569bf18518202df9a43c09f3 (diff)
downloadgitolfs3-f033c6889e0071b29e75c551586e8e5da1b556a3.tar.gz
gitolfs3-f033c6889e0071b29e75c551586e8e5da1b556a3.zip
Use serde_json::json! instead of manually generating JSON
Diffstat (limited to 'common')
-rw-r--r--common/src/lib.rs21
1 files changed, 0 insertions, 21 deletions
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<B: AsRef<[u8]>> fmt::Display for HexFmt<B> {
254 } 254 }
255} 255}
256 256
257pub struct EscJsonFmt<'a>(pub &'a str);
258
259impl<'a> fmt::Display for EscJsonFmt<'a> {
260 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
261 let EscJsonFmt(buf) = self;
262 for c in buf.chars() {
263 match c {
264 '"' => f.write_str("\\\"")?, // quote
265 '\\' => f.write_str("\\\\")?, // backslash
266 '\x08' => f.write_str("\\b")?, // backspace
267 '\x0C' => f.write_str("\\f")?, // form feed
268 '\n' => f.write_str("\\n")?, // line feed
269 '\r' => f.write_str("\\r")?, // carriage return
270 '\t' => f.write_str("\\t")?, // horizontal tab
271 _ => f.write_char(c)?,
272 };
273 }
274 Ok(())
275 }
276}
277
278#[derive(Debug, Copy, Clone)] 257#[derive(Debug, Copy, Clone)]
279pub struct Digest<const N: usize> { 258pub struct Digest<const N: usize> {
280 inner: [u8; N], 259 inner: [u8; N],