Skip to content

Commit f5003d8

Browse files
committed
glib-macros: update docs for property's default parameter
1 parent 9fc8980 commit f5003d8

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

glib-macros/src/lib.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -525,9 +525,12 @@ pub fn closure_local(item: TokenStream) -> TokenStream {
525525
/// }
526526
/// ```
527527
///
528-
/// When using the [`Properties`] macro with enums that derive [`Enum`], the default value must be
529-
/// explicitly set via the `builder` parameter of the `#[property]` attribute. See
530-
/// [here](Properties#supported-types) for details.
528+
/// When using the [`Properties`] macro with enums that derive [`Enum`], the
529+
/// default value can be explicitly set via the `builder` parameter of the
530+
/// `#[property]` attribute. If the enum implements or derives
531+
/// `Default`, you can specify that should be the default value
532+
/// via the `default` parameter. See [here](Properties#supported-types) for
533+
/// details.
531534
///
532535
/// An enum can be registered as a dynamic type by setting the derive macro
533536
/// helper attribute `enum_dynamic`:
@@ -1333,7 +1336,8 @@ pub fn cstr_bytes(item: TokenStream) -> TokenStream {
13331336
/// | `construct` | Specify that the property is construct property. Ensures that the property is always set during construction (if not explicitly then the default value is used). The use of a custom internal setter is supported. | | `#[property(get, construct)]` or `#[property(get, set = set_prop, construct)]` |
13341337
/// | `construct_only` | Specify that the property is construct only. This will not generate a public setter and only allow the property to be set during object construction. The use of a custom internal setter is supported. | | `#[property(get, construct_only)]` or `#[property(get, set = set_prop, construct_only)]` |
13351338
/// | `builder(<required-params>)[.ident]*` | Used to input required params or add optional Param Spec builder fields | | `#[property(builder(SomeEnum::default()))]`, `#[builder().default_value(1).minimum(0).maximum(5)]`, etc. |
1336-
/// | `default` | Sets the `default_value` field of the Param Spec builder | | `#[property(default = 1)]` |
1339+
/// | `default` | Sets the param spec builder field to the default value | | `#[property(default)]` |
1340+
/// | `default = expr` | Sets the `default_value` field of the Param Spec builder | | `#[property(default = 1)]` |
13371341
/// | `<optional-pspec-builder-fields> = expr` | Used to add optional Param Spec builder fields | | `#[property(minimum = 0)` , `#[property(minimum = 0, maximum = 1)]`, etc. |
13381342
/// | `<optional-pspec-builder-fields>` | Used to add optional Param Spec builder fields | | `#[property(explicit_notify)]` , `#[property(construct_only)]`, etc. |
13391343
///
@@ -1443,6 +1447,8 @@ pub fn cstr_bytes(item: TokenStream) -> TokenStream {
14431447
/// smart_pointer: Rc<RefCell<String>>,
14441448
/// #[property(get, set, builder(MyEnum::Val))]
14451449
/// my_enum: Cell<MyEnum>,
1450+
/// #[property(get, set, default)]
1451+
/// my_enum_with_default: Cell<MyEnum>,
14461452
/// /// # Getter
14471453
/// ///
14481454
/// /// Get the value of the property `extra_comments`

0 commit comments

Comments
 (0)