But that we have with normal ints, when you assign a big or negative value to, say, UInt8.
Unchecked exceptions could work great in this and similar cases.
How can I make a 1 byte struct like Int8, and optional of it that doesn't add another byte?
struct Int7 { // one byte, values in -64 ... +63 range
private var rawValue: Int8
...
}
struct Int8x { // one byte, values in -127 ... +127 range
private var rawValue: Int8
...
}
var x: Optional<Int7> = .some(42) // still one byte wanted!
var y: Optional<Int8x> = .some(42) // still one byte wanted!
Does it require compiler support?