1 comment

[ 1.6 ms ] story [ 14.6 ms ] thread
The motivation for this was trying to parse a binary file with a discriminated union, with the tag being a single byte representing one of several ASCII characters. Since Swift doesn't have single byte character literals like single-quoted characters in C, UInt8 raw value enums required decimal or hexadecimal integer literals, which really hurts readability; 0x42 is strictly worse than 'B'. As a StringLiteralConvertible, "B" is an acceptable value for a UInt8 case.