Swift Mapping for Enumerations

A Slice enumeration maps to a Swift enumeration that stores raw values of type UInt8 or Int32. For example:

Slice
enum Fruit { Apple, Pear, Orange }

The mapped Swift enumeration is very similar:

Swift
public enum Fruit: UInt8 { 
	case Apple = 0
	case Pear = 1
	case Orange = 2
	public init() {
		self = .Apple
	}
}

The raw value type for the generated enumeration is UInt8 when the largest enumerator value is 255 or less; otherwise, the raw value type is In32

Suppose we modify the Slice definition to include a custom enumerator value:

Slice
enum Fruit { Apple, Pear = 3, Orange }

The generated Swift definition now includes adjusted values for each enumerators:

Swift
public enum Fruit: UInt8 {
    case Apple = 0
    case Pear = 3
    case Orange = 4
    public init() {
        self = .Apple
    }
}