Skip to content

wltrup/BinaryChoice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BinaryChoice

Xcode Swift GitHub tag (latest SemVer) GitHub

IMPORTANT

2024.04.02: This project has been deprecated.

What

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.
///
public protocol BooleanConvertible {
    var booleanDescription: Bool { get }
}

/// A protocol to represent types that can be initialized from a boolean value.
///
public protocol InitializableByBoolean {
    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.
///
public protocol BinaryChoice: InitializableByBoolean, BooleanConvertible {}

/// The Bool type has a natural conformance to *BinaryChoice*.
///
extension Bool: BinaryChoice {

    /// Returns *self*.
    public var booleanDescription: Bool { self }

}

Installation

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.

Author

Wagner Truppel, [email protected]

License

BinaryChoice is available under the MIT license. See the LICENSE file for more info.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages