auto-default 0.1.1

Macro that adds a default field value of `Default::default()` to fields that don't have one
Documentation
# `auto-default`

<!--
NOTE: Do not edit this file, it is generated by `cargo-rdme` using this build:

    cargo install --git https://github.com/angrynode/cargo-rdme --rev 6fdc08b9150c730bac63f037fb9328aee46b7fe8

edit `lib.rs` instead, then re-run `cargo rdme` to re-generate this file 
-->

<!-- cargo-rdme start -->

[![crates.io](https://img.shields.io/crates/v/auto-default?style=flat-square&logo=rust)](https://crates.io/crates/auto-default)
[![docs.rs](https://img.shields.io/badge/docs.rs-auto-default-blue?style=flat-square&logo=docs.rs)](https://docs.rs/auto-default)
![license](https://img.shields.io/badge/license-Apache--2.0_OR_MIT-blue?style=flat-square)
![msrv](https://img.shields.io/badge/msrv-nightly-blue?style=flat-square&logo=rust)
[![github](https://img.shields.io/github/stars/nik-rev/auto-default)](https://github.com/nik-rev/auto-default)

This crate provides an attribute macro `#[auto_default]`, which adds a default field value of
`Default::default()` to fields that do not have one.

```toml
[dependencies]
auto-default = "0.1"
```

Note: `auto-default` has *zero* dependencies. Not even `syn`! The compile times are very fast.

### Showcase

Rust's [default field values](https://github.com/rust-lang/rust/issues/132162) allow
the shorthand `Struct { field, .. }` instead of the lengthy `Struct { field, ..Default::default() }`

For `..` instead of `..Default::default()` to work,
your `Struct` needs **all** fields to have a default value.

This often means `= Default::default()` boilerplate on every field, because it is
very common to want field defaults to be the value of their `Default` implementation

#### Before

```rust
#[derive(Default)]
pub struct Layout {
    order: u32 = Default::default(),
    location: Point = Default::default(),
    size: Size = Default::default(),
    content_size: Size = Default::default(),
    scrollbar_size: Size = Default::default(),
    border: Rect = Default::default(),
    padding: Rect = Default::default(),
    margin: Rect = Default::default(),
}
```

#### With `#[auto_default]`

```rust
#[auto_default]
#[derive(Default)]
pub struct Layout {
    order: u32,
    location: Point,
    size: Size,
    content_size: Size,
    scrollbar_size: Size,
    border: Rect,
    padding: Rect,
    margin: Rect,
}
```

You can apply the [`#[auto_default]`](macro@auto_default) macro to `struct`s with named fields, or enums

If any field or variant has the `#[auto_default(skip)]` attribute, a default field value of `Default::default()`
will not be added

<!-- cargo-rdme end -->