partial_this 0.5.0

Type-safe partial construction
Documentation
# PartialThis


[![Rust](https://github.com/2A5F/partial_this/actions/workflows/rust.yml/badge.svg)](https://github.com/2A5F/partial_this/actions/workflows/rust.yml)
[![Miri](https://github.com/2A5F/partial_this/actions/workflows/miri.yml/badge.svg)](https://github.com/2A5F/partial_this/actions/workflows/miri.yml)
[![Clippy](https://github.com/2A5F/partial_this/actions/workflows/clippy.yml/badge.svg)](https://github.com/2A5F/partial_this/actions/workflows/clippy.yml)
[![version](https://img.shields.io/crates/v/partial_this)](https://crates.io/crates/partial_this)
[![documentation](https://docs.rs/partial_this/badge.svg)](https://docs.rs/partial_this)
![LICENSE](https://img.shields.io/crates/l/partial_this)

Type-safe partial construction

```rust

#[partial]

#[derive(Debug)]

pub struct Foo {
    pub foo: i32,
    pub bar: f32,
}

fn test() {
    let p = Foo::partial(Box::new_uninit());
    let p = p.with_foo(1);
    let p = p.with_bar(1.0);
    let foo: Box<Foo> = p.done();
    println!("{:?}", foo);
}
```

- Multi partial overloads.

  ```rust
  let foo: Box<Foo> = Foo::partial(Box::new_uninit()).done();

  let foo: Foo = Foo::partial(MaybeUninit::uninit()).done();

  let mut foo = MaybeUninit::uninit();
  let foo: &mut Foo = Foo::partial(&mut foo).done();
  ```

- Field initialization methods. Can be called in any order and at most once.
  ```rust
  // ok
  let p = p.with_foo(1);
  let p = p.with_bar(1.0);
  ```
  ```rust
  // ok
  let p = p.with_bar(1.0);
  let p = p.with_foo(1);
  ```
  ```rust
  let p = p.with_foo(1);
  let p = p.with_foo(1); // error
  ```
- Field access methods. Can be called after initialization.
  ```rust
  let p = p.with_foo(1);
  println!("{}", p.get_foo());
  ```
  ```rust
  let mut p = p.with_foo(1);
  p.set_foo(123);
  ```
- Done method.Can be called after all fields are initialized.
  ```rust
  let foo = p.done();
  ```
- Drop safe. Will call fields `drop` according to the field initialization status and in the reverse order of initialization (the last field initialized is dropped first).
  ```rust
  struct Some {
    field0: ...,
    field1: ...,
    field2: ...,
    ...
  }
  let p = Some::partial(Box::new_uninit());
  let p = p.field0(...);
  let p = p.field1(...);
  drop(p); // drop(field1) -> drop(field0) -> drop(Box<MaybeUninit<Some>>)
  ```