nova 0.3.2

Macro to derive newtypes with support for serde and sqlx.
Documentation

nova

Documentation

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.

Usage

[dependencies]
nova = "0.3"

Example

use nova::newtype;

#[newtype(serde, borrow = "str")]
pub type Meow = String;

#[newtype(copy)]
pub(crate) type SpecialUuid = uuid::Uuid;

fn example() {
    let meow = Meow("this is a string".to_string());
    let special_uuid = SpecialUuid(uuid::Uuid::new_v4());

    // Get inner:
    let inner = special_uuid.into_inner();
}

Features

  • serde: enables support for the serde attribute to derive Serialize and Deserialize for newtypes.

License

This project is licensed under either of

at your option.