From 86e30297b9b28d4dca4918d46570ff71be8db591 Mon Sep 17 00:00:00 2001 From: acdenisSK Date: Sun, 17 Sep 2017 13:11:43 +0200 Subject: if let -> and_then/map --- src/model/channel/attachment.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src/model') diff --git a/src/model/channel/attachment.rs b/src/model/channel/attachment.rs index 5d47469..af15bf7 100644 --- a/src/model/channel/attachment.rs +++ b/src/model/channel/attachment.rs @@ -32,11 +32,7 @@ impl Attachment { /// If this attachment is an image, then a tuple of the width and height /// in pixels is returned. pub fn dimensions(&self) -> Option<(u64, u64)> { - if let (Some(width), Some(height)) = (self.width, self.height) { - Some((width, height)) - } else { - None - } + self.width.and_then(|width| self.height.map(|height| (width, height))) } /// Downloads the attachment, returning back a vector of bytes. -- cgit v1.2.3