From 87436c10578c47bab3883198add74caa9c0e9844 Mon Sep 17 00:00:00 2001 From: Tae Won Ha Date: Thu, 10 Dec 2020 21:47:25 +0100 Subject: [PATCH] Reformat --- .../Sources/NvimView/MessagePackCommons.swift | 29 +++++++------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/NvimView/Sources/NvimView/MessagePackCommons.swift b/NvimView/Sources/NvimView/MessagePackCommons.swift index fe95fe8f..96ed1596 100644 --- a/NvimView/Sources/NvimView/MessagePackCommons.swift +++ b/NvimView/Sources/NvimView/MessagePackCommons.swift @@ -7,33 +7,29 @@ import Foundation import MessagePack extension MessagePackValue { - var intValue: Int? { - guard let i64 = self.int64Value else { - return nil - } + guard let i64 = self.int64Value else { return nil } return Int(i64) } } -class MessagePackUtils { - +enum MessagePackUtils { static func value(from data: Data?, conversion: (MessagePackValue) -> T?) -> T? { guard let d = data else { return nil } - do { - return conversion(try unpack(d).value) - } catch { - return nil - } + do { return conversion(try unpack(d).value) } + catch { return nil } } static func value(from v: MessagePackValue, conversion: (MessagePackValue) -> T?) -> T? { - return conversion(v) + conversion(v) } - static func array(from value: MessagePackValue, ofSize size: Int, conversion: (MessagePackValue) -> T?) -> [T]? { + static func array( + from value: MessagePackValue, ofSize size: Int, + conversion: (MessagePackValue) -> T? + ) -> [T]? { guard let array = value.arrayValue else { return nil } guard array.count == size else { return nil } @@ -43,10 +39,7 @@ class MessagePackUtils { static func value(from data: Data?) -> MessagePackValue? { guard let d = data else { return nil } - do { - return try unpack(d).value - } catch { - return nil - } + do { return try unpack(d).value } + catch { return nil } } }