Skip to content

Commit

Permalink
Merge #971
Browse files Browse the repository at this point in the history
971: Add docs for the `#[variant(enum)]` attribute. r=Bromeon a=chitoyuu

Follow-up to #964

Co-authored-by: Chitose Yuuzaki <[email protected]>
  • Loading branch information
bors[bot] and chitoyuu authored Oct 31, 2022
2 parents 58db05f + 57dca06 commit 0b3341c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion gdnative-core/src/core_types/variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -709,10 +709,23 @@ godot_test!(
/// - `Struct { a, b, c }` is represented as a `Dictionary` (`{ "a": a, "b": b, "c": c }`)
/// - `Unit` is represented as an empty `Dictionary` (`{}`)
/// - `Enum::Variant(a, b, c)` is represented as an externally tagged `Dictionary`
/// (`{ "Variant": [a, b, c] }`)
/// (`{ "Variant": [a, b, c] }`), unless another representation is specified with
/// `#[variant(enum)]` (see below).
///
/// Behavior of the derive macros can be customized using attributes:
///
/// ### Item attributes
///
/// - `#[variant(enum = "str")]`
///
/// Only applicable to field-less enums. Variants of types annotated with this attribute
/// are represented as stringified values of their names, i.e. `"Variant"` for `Enum::Variant`.
///
/// - `#[variant(enum = "repr")]`
///
/// Only applicable to field-less enums with a explicit primitive `#[repr]` type. Variants of
/// types annotated with this attribute are represented as their primitive integral values.
///
/// ### Field attributes
///
/// - `#[variant(to_variant_with = "path::to::func")]`
Expand Down

0 comments on commit 0b3341c

Please sign in to comment.