Add documentation

This commit is contained in:
Jacob Pratt 2022-03-08 15:44:52 -05:00
parent abf2b4c04d
commit a3dd654ae9
No known key found for this signature in database
GPG Key ID: B80E19E4662B5AA4

View File

@ -52,6 +52,23 @@
/// 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.
///
/// ### `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`?
///
/// Provide an implementation for the `default()` method that returns the value of