Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[derive] Rename is_c_like -> is_fieldless
The implementation of this method checks for the presence of fields. While this is /similar/ to the concept of a C-like enum, it's not the same. Fieldless enums are exactly as described: none of their variants has fields. C-like enums, on the other hand, are more recently referred to as "unit-only" because their variants are not permitted to contain parentheses or curly braces. E.g., the following is a fieldless enum, but is not a C-like/unit-only enum: #[repr(u8)] enum Foo { A, // This is fine B(), // This is not fine C{} // This is not fine } This distinction is important specifically when it comes to discriminants. The syntax `Foo::A as u8` computes the discriminant value of the `A` variant. However, `Foo::B` is a type constructor, and thus is a function. As a result, `Foo::B as u8` computes the address of the function `Foo::B`.
- Loading branch information