mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Import MacTypes.Boolean as a dedicated DarwinBoolean type.
Like ObjCBool is a legitimate boolean type rather than a typealias for Int8, DarwinBoolean is better than a typealias for UInt8. It's a BooleanType (meaning you can use it directly in if/while/?:) and BooleanLiteralConvertible (meaning you can use 'true' and 'false'). The next commit goes even further, so that you only have to deal with DarwinBoolean when ABI is important. At all other times it should be bridged with Bool, just like ObjCBool. rdar://problem/19013551 Swift SVN r30050
This commit is contained in:
@@ -18,8 +18,8 @@
|
||||
/// the condition in control statements (`if`, `while`, C-style `for`)
|
||||
/// and other logical value contexts (e.g., `case` statement guards).
|
||||
///
|
||||
/// Only two types provided by Swift, `Bool` and `ObjCBool`, conform
|
||||
/// to `BooleanType`. Expanding this set to include types that
|
||||
/// Only three types provided by Swift, `Bool`, `DarwinBoolean`, and `ObjCBool`,
|
||||
/// conform to `BooleanType`. Expanding this set to include types that
|
||||
/// represent more than simple boolean values is discouraged.
|
||||
public protocol BooleanType {
|
||||
/// The value of `self`, expressed as a `Bool`.
|
||||
|
||||
Reference in New Issue
Block a user