.cloned()
instead of .map(|x| x.clone())
263 }
264
265 async fn get_webhook(&self, ctx: &Context, channel: &ChannelId) -> Webhook {
266 let hook = self.webhook_cache.get(channel).map(|x| x.clone());267 if let Some(hook) = hook {
268 return hook;
269 }
.map(|x| x.clone())
is equivalent to calling .cloned()
, which is more readable.
let a = ["1", "two", "NaN", "four", "5"];
let iter_with_string = a.iter().map(|s| s.clone());
let a = ["1", "two", "NaN", "four", "5"];
let iter_with_string = a.iter().cloned();