derive-ex

Crates.io Docs.rs Actions Status

Improved version of the macro to implement the traits defined in the standard library.

Documentation

See #[derive_ex] documentation for details.

Differences from standard derive macros

Supported traits

Unsupported traits

The following traits are not supported as more suitable crates exist.

| trait | crate | | -------------------- | --------------------------------------------------------- | | Display, FromStr | parse-display | | Error | thiserror |

Install

Add this to your Cargo.toml:

toml [dependencies] derive-ex = "0.1.2"

Example

```rust use deriveex::deriveex;

[derive(Eq, PartialEq, Debug)]

[derive_ex(Add, AddAssign, Clone, Default)]

struct X { #[default(10)] a: u32, } asserteq!(X { a: 1 } + X { a: 2 }, X { a: 3 }); asserteq!(X::default(), X { a: 10 });

[derive(Eq, PartialEq, Debug)]

[derive_ex(Clone, Default)]

enum Y { A, #[default] B, } assert_eq!(Y::default(), Y::B); ```

License

This project is dual licensed under Apache-2.0/MIT. See the two LICENSE-* files for details.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.