Crates.io | struct_fragment |
lib.rs | struct_fragment |
version | 0.0.1 |
source | src |
created_at | 2021-01-29 07:43:11.313335 |
updated_at | 2021-01-29 07:43:11.313335 |
description | A macro to create a duplicate of a struct with keys removed. |
homepage | |
repository | |
max_upload_size | |
id | 347902 |
size | 6,493 |
A macro to create a duplicate of a struct with keys removed.
I mainly developed this macro to help with creating structs for interacting with the diesel
create:
id
removed, used for inserts into the databasePOST
body.Either providing a list of ignored fields:
#[derive(StructFragment)]
#[fragment_ignore_list = "id,updated_at"]
#[fragment_name = "DbUser"]
pub struct User {
pub id: i32,
pub full_name: String,
pub email: String,
pub updated_at: DateTime
}
Or adding #[fragment_ignore]
to fields you don't want included.
#[derive(StructFragment)]
#[fragment_name = "DbUser"]
pub struct User {
#[fragment_ignore] pub id: i32,
pub full_name: String,
pub email: String,
#[fragment_ignore] pub updated_at: DateTime
}