- Notifications
You must be signed in to change notification settings - Fork 10.5k
/
Copy pathoption_set.swift
29 lines (22 loc) · 849 Bytes
/
option_set.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// REQUIRES: swift_swift_parser, executable_test
// RUN: %target-run-simple-swift(-Xfrontend -plugin-path -Xfrontend %swift-plugin-dir -emit-tbd -emit-tbd-path %t.tbd)
import Swift
@attached(member, names:named(RawValue),named(rawValue),named(`init`), arbitrary)
@attached(extension, conformances: OptionSet)
public macro OptionSet<RawType>()=
#externalMacro(module:"SwiftMacros", type:"OptionSetMacro")
@OptionSet<UInt8>
structShippingOptions{
privateenumOptions:Int{
case nextDay
case secondDay
case priority
case standard
}
staticletexpress:ShippingOptions=[.nextDay,.secondDay]
staticletall:ShippingOptions=[.express,.priority,.standard]
}
letoptions=ShippingOptions.express
assert(options.contains(.nextDay))
assert(options.contains(.secondDay))
assert(!options.contains(.standard))