@@ -44,9 +44,21 @@ Finally, inference for `as` will be modified to track the types
44
44
a value is being cast * to* for cases where the value being cast
45
45
is unconstrained, like ` 0 as u8 ` .
46
46
47
+ Treatment of enum discriminants will need to change:
48
+
49
+ ```
50
+ enum Color { Red = 0, Green = 1, Blue = 2 }
51
+ ```
52
+
53
+ Currently, an unsuffixed integer defaults to ` int ` . Instead, we will
54
+ only require enum descriminants primitive integers of unspecified
55
+ type; assigning an integer to an enum will behave as if casting from
56
+ from the type of the integer to an unsigned integer with the size of
57
+ the enum discriminant.
58
+
47
59
# Drawbacks
48
60
49
- This will force users to cast somewhat more often. In particular,
61
+ This will force users to type hint somewhat more often. In particular,
50
62
ranges of unsigned ints may need to be type-hinted:
51
63
52
64
```
@@ -61,13 +73,3 @@ Do none of this.
61
73
62
74
* If we're putting new restrictions on shift operators, should we
63
75
change the traits, or just make the primitives special?
64
-
65
- There is some question about how to treat enum discriminants:
66
-
67
- ```
68
- enum Color { Red = 0, Green = 1, Blue = 2 }
69
- ```
70
-
71
- Currently these default to ` int ` , but we need to change the
72
- behavior. Niko suggests just making discriminants always ` int ` , but
73
- how does that interact with ` repr ` ?
0 commit comments