Skip to content

Instantly share code, notes, and snippets.

@muukii
Created October 1, 2014 05:34
Show Gist options
  • Save muukii/9e7fab33a4f0e685d5de to your computer and use it in GitHub Desktop.
Save muukii/9e7fab33a4f0e685d5de to your computer and use it in GitHub Desktop.
Swift bit
private struct FavoritesModelConnectingType: RawOptionSetType {
private var value: UInt = 0
init(_ value: UInt) {
self.value = value
}
// MARK: RawOptionSetType
static func fromMask(raw: UInt) -> FavoritesModelConnectingType {
return self(raw)
}
// MARK: RawRepresentable
static func fromRaw(raw: UInt) -> FavoritesModelConnectingType? {
return self(raw)
}
func toRaw() -> UInt {
return value
}
// MARK: BooleanType
var boolValue: Bool {
return value != 0
}
// MARK: BitwiseOperationsType
static var allZeros: FavoritesModelConnectingType {
return self(0)
}
// MARK: NilLiteralConvertible
static func convertFromNilLiteral() -> FavoritesModelConnectingType {
return self(0)
}
static var FavoritesList: FavoritesModelConnectingType { return self(1 << 0) }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment