From e152b3cc54b44840a5baf67d2e320dd1a24750a2 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Mon, 15 Feb 2021 15:31:41 +0100 Subject: [PATCH] client-api: Shorten Capabilities::get --- .../src/r0/capabilities/get_capabilities.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/ruma-client-api/src/r0/capabilities/get_capabilities.rs b/ruma-client-api/src/r0/capabilities/get_capabilities.rs index f2956a10..edbc0cbd 100644 --- a/ruma-client-api/src/r0/capabilities/get_capabilities.rs +++ b/ruma-client-api/src/r0/capabilities/get_capabilities.rs @@ -84,15 +84,11 @@ impl Capabilities { /// Returns value of the given capability. pub fn get(&self, capability: &str) -> serde_json::Result>> { - let value = match capability { + Ok(match capability { "m.change_password" => Some(Cow::Owned(to_json_value(&self.change_password)?)), "m.room_versions" => Some(Cow::Owned(to_json_value(&self.room_versions)?)), - _ => match self.custom_capabilities.get(capability) { - Some(value) => Some(Cow::Borrowed(value)), - None => None, - }, - }; - Ok(value) + _ => self.custom_capabilities.get(capability).map(Cow::Borrowed), + }) } /// Sets the given value to a capability.