From c8c38ac1d42085d2070ef643b219ac667738d94f Mon Sep 17 00:00:00 2001 From: projectmoon Date: Sun, 29 Nov 2020 16:55:23 +0000 Subject: [PATCH] Avoid nested map when retrieving room info from db. --- src/db/rooms.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/db/rooms.rs b/src/db/rooms.rs index af6b1a2..6d7380e 100644 --- a/src/db/rooms.rs +++ b/src/db/rooms.rs @@ -237,12 +237,13 @@ impl Rooms { pub fn get_room_info(&self, info: &RoomInfo) -> Result, DataError> { let key = info.room_id.as_bytes(); - //swap/flatten Result> down into the return type. - self.roomid_roominfo - .get(key) - .map(|bytes| bytes.map(|b| bincode::deserialize::(&b)))? - .transpose() - .map_err(|e| e.into()) + let room_info: Option = self + .roomid_roominfo + .get(key)? + .map(|bytes| bincode::deserialize(&bytes)) + .transpose()?; + + Ok(room_info) } pub fn get_rooms_for_user(&self, username: &str) -> Result, DataError> {