From 01c106228b5d18606d64d7fd863caa6146155bc2 Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Mon, 25 Oct 2021 20:00:22 +0300 Subject: [PATCH] [swcomp] Replace ConvertibleFromString extension for BZip2.BlockSize with an empty conformance SwiftCLI provides a default implementation for enums with Int raw values. --- Sources/swcomp/Archives/BZip2Command.swift | 5 +++++ .../BlockSize+ConvertibleFromString.swift | 19 ------------------- 2 files changed, 5 insertions(+), 19 deletions(-) delete mode 100644 Sources/swcomp/Extensions/BlockSize+ConvertibleFromString.swift diff --git a/Sources/swcomp/Archives/BZip2Command.swift b/Sources/swcomp/Archives/BZip2Command.swift index de2945c5..18bbfd2f 100644 --- a/Sources/swcomp/Archives/BZip2Command.swift +++ b/Sources/swcomp/Archives/BZip2Command.swift @@ -7,6 +7,11 @@ import Foundation import SWCompression import SwiftCLI +// This extension allows to use BZip2.BlockSize as a Key option. +// The extension is empty because there is a default implementation for a ConvertibleFromString when the RawValue type +// of the enum (Int, in this case) is ConvertibleFromString itself. +extension BZip2.BlockSize: ConvertibleFromString {} + class BZip2Command: Command { let name = "bz2" diff --git a/Sources/swcomp/Extensions/BlockSize+ConvertibleFromString.swift b/Sources/swcomp/Extensions/BlockSize+ConvertibleFromString.swift deleted file mode 100644 index 1a4a51fa..00000000 --- a/Sources/swcomp/Extensions/BlockSize+ConvertibleFromString.swift +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2021 Timofey Solomko -// Licensed under MIT License -// -// See LICENSE for license information - -import Foundation -import SwiftCLI -import SWCompression - -/// This extension allows to use `BlockSize` as a `Key` option. -extension BZip2.BlockSize: ConvertibleFromString { - - public static func convert(from: String) -> BZip2.BlockSize? { - guard let num = Int(from) - else { return nil } - return BZip2.BlockSize(rawValue: num) - } - -}