Create newtypes with great convenience.
All types generated by the following macros implement Debug
, Clone
, Eq
, PartialEq
, Ord
, PartialOrd
and Hash
. For Copy
types, the newtype also implements Copy
.
For convenience, each type is also generated with a conditional derive for serde serialisation and deserialisation. This is enabled
with the serde
feature, if desired.
toml
[dependencies]
nova = "0.3"
```rust use nova::newtype;
pub type Meow = String;
pub(crate) type SpecialUuid = uuid::Uuid;
fn example() { let meow = Meow("this is a string".tostring()); let specialuuid = SpecialUuid(uuid::Uuid::new_v4());
// Get inner:
let inner = special_uuid.into_inner();
}
```
serde
attribute to derive Serialize
and Deserialize
for newtypes.This project is licensed under either of
at your option.