When creating an option set, include a rawValue property in your type declaration. For your type to automatically receive default implementations for set-related operations, the rawValueproperty must be of a type that conforms to the FixedWidthInteger protocol, such as Intor UInt8.
Next, create unique options as static properties of your custom type using unique powers of two (1, 2, 4, 8, 16 ...) for each individual propertyโs raw value so that each property can be represented by a single bit of the typeโs raw value.
structShippingOptions:OptionSet{let rawValue: Int// โญ๏ธ unit sets (containing only one element)staticlet nextDay =ShippingOptions(rawValue:1<<0)staticlet secondDay =ShippingOptions(rawValue:1<<1)staticlet priority =ShippingOptions(rawValue:1<<2)staticlet standard =ShippingOptions(rawValue:1<<3)// โญ๏ธ useful sets (containing multiple elements)// โญ๏ธ can be initialized by array literal (ExpressibleByArrayLiteral)staticlet express: ShippingOptions = [.nextDay, .secondDay]staticlet all: ShippingOptions = [.express, .priority, .standard]}// โญ๏ธ empty setlet noOptions: ShippingOptions = []