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
.
toml
[dependencies]
nova = "0.4"
```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::from(uuid::Uuid::new_v4());
// Get inner:
let inner = special_uuid.into_inner();
}
```
serde
attribute to derive Serialize
and Deserialize
for newtypes.sqlx
attribute to derive sqlx::Type
for newtypes.async_graphql
attribute to implement Scalar
for newtypes.Copy
on the newtype.Deref
and into_inner
functions to create an opaque type.Deref
implementation, if needed.new
function and From
implementation.This project is licensed under either of
at your option.