diff options
author | Lars Wirzenius <liw@liw.fi> | 2020-09-18 19:15:10 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2020-09-18 19:50:46 +0300 |
commit | 71e7bf07fd9efd17da40e077babbf634113f8fed (patch) | |
tree | 2e08541bbede3e5dacdd7fe1bce2e1b0da55ae4e | |
parent | e4457fa26afb27b227674c5dd1284a26127dcea6 (diff) | |
download | obnam2-71e7bf07fd9efd17da40e077babbf634113f8fed.tar.gz |
use to_string method for ChunkId instead of format! macro
-rw-r--r-- | src/bin/obnam-server.rs | 2 | ||||
-rw-r--r-- | src/chunkid.rs | 8 | ||||
-rw-r--r-- | src/server.rs | 2 |
3 files changed, 6 insertions, 6 deletions
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<Self> { |