mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
Add documentation
This commit is contained in:
parent
abf2b4c04d
commit
a3dd654ae9
@ -52,6 +52,23 @@
|
|||||||
/// This trait can be used with `#[derive]` if all of the type's fields implement
|
/// This trait can be used with `#[derive]` if all of the type's fields implement
|
||||||
/// `Default`. When `derive`d, it will use the default value for each field's type.
|
/// `Default`. When `derive`d, it will use the default value for each field's type.
|
||||||
///
|
///
|
||||||
|
/// ### `enum`s
|
||||||
|
///
|
||||||
|
/// When using `#[derive(Default)]` on an `enum`, you need to choose which unit variant will be
|
||||||
|
/// default. You do this by placing the `#[default]` attribute on the variant.
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// #[derive(Default)]
|
||||||
|
/// enum Kind {
|
||||||
|
/// #[default]
|
||||||
|
/// A,
|
||||||
|
/// B,
|
||||||
|
/// C,
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// You cannot use the `#[default]` attribute on non-unit or non-exhaustive variants.
|
||||||
|
///
|
||||||
/// ## How can I implement `Default`?
|
/// ## How can I implement `Default`?
|
||||||
///
|
///
|
||||||
/// Provide an implementation for the `default()` method that returns the value of
|
/// Provide an implementation for the `default()` method that returns the value of
|
||||||
|
Loading…
Reference in New Issue
Block a user