Crates.io | derive-ex |
lib.rs | derive-ex |
version | 0.1.8 |
source | src |
created_at | 2022-05-05 04:57:38.459768 |
updated_at | 2024-05-05 01:54:18.240316 |
description | Improved version of the macro to implement the traits defined in the standard library. |
homepage | |
repository | https://github.com/frozenlib/derive-ex |
max_upload_size | |
id | 580817 |
size | 141,003 |
Improved version of the macro to implement the traits defined in the standard library.
See #[derive_ex]
documentation for details.
Debug
.Clone::clone_from
.Add
, AddAssign
, Not
, Deref
, etc.)Copy
Clone
Debug
Default
Ord
, PartialOrd
, Eq
, PartialEq
, Hash
Add
, Sub
, Mul
, Shl
, etc.)AddAssign
, SubAssign
, MulAssign
, ShlAssign
, etc.)Not
, Neg
)Deref
, DerefMut
The following traits are not supported as more suitable crates exist.
trait | crate |
---|---|
Display , FromStr |
parse-display |
Error |
thiserror |
Add this to your Cargo.toml:
[dependencies]
derive-ex = "0.1.7"
use derive_ex::derive_ex;
#[derive(Eq, PartialEq, Debug)]
#[derive_ex(Add, AddAssign, Clone, Default)]
struct X {
#[default(10)]
a: u32,
}
assert_eq!(X { a: 1 } + X { a: 2 }, X { a: 3 });
assert_eq!(X::default(), X { a: 10 });
#[derive(Eq, PartialEq, Debug)]
#[derive_ex(Clone, Default)]
enum Y {
A,
#[default]
B,
}
assert_eq!(Y::default(), Y::B);
This project is dual licensed under Apache-2.0/MIT. See the two LICENSE-* files for details.
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.