# `impl-more`

> Concise trait implementations.

<!-- prettier-ignore-start -->

[![crates.io](https://img.shields.io/crates/v/impl-more?label=latest)](https://crates.io/crates/impl-more)
[![Documentation](https://docs.rs/impl-more/badge.svg)](https://docs.rs/impl-more/0.1.6)
![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/impl-more.svg)
<br />
[![dependency status](https://deps.rs/crate/impl-more/0.1.6/status.svg)](https://deps.rs/crate/impl-more/0.1.6)
[![Download](https://img.shields.io/crates/d/impl-more.svg)](https://crates.io/crates/impl-more)
[![CircleCI](https://circleci.com/gh/robjtede/impl-more/tree/main.svg?style=shield)](https://circleci.com/gh/robjtede/impl-more/tree/main)

<!-- prettier-ignore-end -->

# Usage

```rust
struct MyNewTypeStruct(String);

impl_more::impl_as_ref!(MyNewTypeStruct => String);
impl_more::impl_as_mut!(MyNewTypeStruct => String);

impl_more::impl_deref!(MyNewTypeStruct => String);
impl_more::impl_deref_mut!(MyNewTypeStruct);
// or, to deref through String too:
// impl_more::forward_deref_and_mut!(MyNewTypeStruct, ref str);

impl_more::impl_from!(String => MyNewTypeStruct);
impl_more::impl_into!(MyNewTypeStruct => String);

enum MyEnum {
    Bar,
    Qux,
}

impl_more::impl_display_enum!(MyEnum, Bar => "bar", Qux => "qux");

enum Coords {
    Xy(i64, i64),
    Xyz(i64, i64, i64),
}

impl_more::impl_display_enum!(
    Coords,
    Xy(x, y) => "{x}, {y}",
    Xyz(x, y, z) => "{x}, {y}, {z}",
);

#[derive(Debug)]
struct MyError(eyre::Report);

impl_more::forward_display!(MyError);
impl_more::forward_error!(MyError);

let err = MyError(eyre::eyre!("something went wrong"));
assert_eq!(err.source().unwrap().to_string(), "something went wrong");

#[derive(Debug)]
enum Err {
    Io(std::io::Error),
    Generic(String),
}

impl_more::impl_display_enum!(Err, Io(err) => "{err}", Generic(msg) => "{msg}");
impl_more::impl_error_enum!(Err, Io(err) => err);
```
