From 71e7bf07fd9efd17da40e077babbf634113f8fed Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Fri, 18 Sep 2020 19:15:10 +0300 Subject: use to_string method for ChunkId instead of format! macro --- src/bin/obnam-server.rs | 2 +- src/chunkid.rs | 8 ++++---- src/server.rs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/bin/obnam-server.rs b/src/bin/obnam-server.rs index 40ea400..3adf2eb 100644 --- a/src/bin/obnam-server.rs +++ b/src/bin/obnam-server.rs @@ -174,7 +174,7 @@ impl warp::Reply for ChunkResult { match self { ChunkResult::Created(id) => { let body = CreatedBody { - chunk_id: format!("{}", id), + chunk_id: id.to_string(), }; let body = serde_json::to_string(&body).unwrap(); let mut r = warp::reply::Response::new(body.into()); diff --git a/src/chunkid.rs b/src/chunkid.rs index ba301a1..44a76d6 100644 --- a/src/chunkid.rs +++ b/src/chunkid.rs @@ -57,9 +57,9 @@ mod test { use super::ChunkId; #[test] - fn displayable() { + fn to_string() { let id = ChunkId::new(); - assert_ne!(format!("{}", id), "") + assert_ne!(id.to_string(), "") } #[test] @@ -73,13 +73,13 @@ mod test { fn recreatable() { let id_str = "xyzzy"; // it doesn't matter what the string representation is let id: ChunkId = id_str.parse().unwrap(); - assert_eq!(format!("{}", id), id_str); + assert_eq!(id.to_string(), id_str); } #[test] fn survives_round_trip() { let id = ChunkId::new(); - let id_str = format!("{}", id); + let id_str = id.to_string(); assert_eq!(id, id_str.parse().unwrap()); } } diff --git a/src/server.rs b/src/server.rs index 7498050..8d1eed0 100644 --- a/src/server.rs +++ b/src/server.rs @@ -47,7 +47,7 @@ pub struct SearchHits { impl SearchHits { pub fn insert(&mut self, id: ChunkId, meta: ChunkMeta) { - self.map.insert(format!("{}", id), meta); + self.map.insert(id.to_string(), meta); } pub fn from_json(s: &str) -> anyhow::Result { -- cgit v1.2.1