Skip to content

Commit 0b3341c

Browse files
bors[bot]chitoyuu
andauthored
Merge #971
971: Add docs for the `#[variant(enum)]` attribute. r=Bromeon a=chitoyuu Follow-up to #964 Co-authored-by: Chitose Yuuzaki <chitoyuu@potatoes.gay>
2 parents 58db05f + 57dca06 commit 0b3341c

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

gdnative-core/src/core_types/variant.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,10 +709,23 @@ godot_test!(
709709
/// - `Struct { a, b, c }` is represented as a `Dictionary` (`{ "a": a, "b": b, "c": c }`)
710710
/// - `Unit` is represented as an empty `Dictionary` (`{}`)
711711
/// - `Enum::Variant(a, b, c)` is represented as an externally tagged `Dictionary`
712-
/// (`{ "Variant": [a, b, c] }`)
712+
/// (`{ "Variant": [a, b, c] }`), unless another representation is specified with
713+
/// `#[variant(enum)]` (see below).
713714
///
714715
/// Behavior of the derive macros can be customized using attributes:
715716
///
717+
/// ### Item attributes
718+
///
719+
/// - `#[variant(enum = "str")]`
720+
///
721+
/// Only applicable to field-less enums. Variants of types annotated with this attribute
722+
/// are represented as stringified values of their names, i.e. `"Variant"` for `Enum::Variant`.
723+
///
724+
/// - `#[variant(enum = "repr")]`
725+
///
726+
/// Only applicable to field-less enums with a explicit primitive `#[repr]` type. Variants of
727+
/// types annotated with this attribute are represented as their primitive integral values.
728+
///
716729
/// ### Field attributes
717730
///
718731
/// - `#[variant(to_variant_with = "path::to::func")]`

0 commit comments

Comments
 (0)