| Crates.io | nova |
| lib.rs | nova |
| version | 0.5.4 |
| created_at | 2021-06-27 21:20:19.145296+00 |
| updated_at | 2022-08-12 09:39:44.881971+00 |
| description | Macro to derive newtypes with support for serde and sqlx. |
| homepage | |
| repository | https://github.com/bbqsrc/nova |
| max_upload_size | |
| id | 415519 |
| size | 16,384 |
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.
[dependencies]
nova = "0.4"
use nova::newtype;
#[newtype(serde, borrow = "str")]
pub type Meow = String;
#[newtype(new, copy)]
pub(crate) type SpecialUuid = uuid::Uuid;
fn example() {
let meow = Meow("this is a string".to_string());
let special_uuid = 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.#[derive(...)] attribute.This project is licensed under either of
at your option.