2024.04.02: This project has been deprecated.
BinaryChoice is a Swift Package Manager package for iOS/tvOS (10.0 and above), watchOS (4.0 and above), and macOS (10.14 and above), under Swift 5.0 and above, defining protocols for types that can be initialised from a boolean value and/or can be represented by a boolean value:
/// A protocol to represent types that have a boolean representation.
///
publicprotocolBooleanConvertible{varbooleanDescription:Bool{get}}
/// A protocol to represent types that can be initialized from a boolean value.
///
publicprotocolInitializableByBoolean{init(_ value:Bool)}
/// A protocol to represent types having only two values, which can then be
/// mapped to *true* and *false* in a one-to-one fashion, in both directions.
///
publicprotocolBinaryChoice:InitializableByBoolean,BooleanConvertible{}
/// The Bool type has a natural conformance to *BinaryChoice*.
///
extensionBool:BinaryChoice{
/// Returns *self*.
publicvarbooleanDescription:Bool{self}}BinaryChoice is provided only as a Swift Package Manager package, because I'm moving away from CocoaPods and Carthage, and can be easily installed directly from Xcode.
Wagner Truppel, trupwl@gmail.com
BinaryChoice is available under the MIT license. See the LICENSE file for more info.