mirror of
https://github.com/LemmyNet/lemmy
synced 2024-11-23 04:53:06 +00:00
Update without_id.rs
This commit is contained in:
parent
a364135e5a
commit
e26107a2fe
1 changed files with 46 additions and 42 deletions
|
@ -22,19 +22,23 @@ macro_rules! WithoutId {
|
||||||
$(#[$_id_meta:meta])*
|
$(#[$_id_meta:meta])*
|
||||||
$_id_vis:vis id: $id_type:ty,
|
$_id_vis:vis id: $id_type:ty,
|
||||||
$(
|
$(
|
||||||
$(#[$_field_meta:meta])*
|
// TODO: more flexible attribute matching
|
||||||
|
$(#[doc = $_doc1:tt])*
|
||||||
|
$(#[cfg($($cfgtt:tt)*)])*
|
||||||
|
$(#[cfg_attr($($cfgattrtt:tt)*)])*
|
||||||
|
$(#[serde($($serdett:tt)*)])*
|
||||||
|
$(#[doc = $_doc2:tt])*
|
||||||
$field_vis:vis $field_name:ident : $field_type:ty,
|
$field_vis:vis $field_name:ident : $field_type:ty,
|
||||||
)*
|
)*
|
||||||
}
|
}
|
||||||
) => {
|
) => {
|
||||||
::paste::paste! {
|
::paste::paste! {
|
||||||
#[derive(::diesel::Queryable, ::diesel::Selectable)]
|
// TODO: remove serde derives
|
||||||
|
#[derive(::diesel::Queryable, ::diesel::Selectable, ::serde::Serialize, ::serde::Deserialize)]
|
||||||
#[diesel(table_name = $table_name)]
|
#[diesel(table_name = $table_name)]
|
||||||
$vis struct [<$struct_name WithoutId>] {
|
$vis struct [<$struct_name WithoutId>] {
|
||||||
$(
|
$(
|
||||||
// Field attributes are not kept because either they are for other
|
$(#[cfg($($cfgtt)*)])*
|
||||||
// derive macros, or they are `#[cfg(...)]` which is evaluated before
|
|
||||||
// macro expansion.
|
|
||||||
$field_vis $field_name : $field_type,
|
$field_vis $field_name : $field_type,
|
||||||
)*
|
)*
|
||||||
}
|
}
|
||||||
|
@ -42,8 +46,8 @@ macro_rules! WithoutId {
|
||||||
impl [<$struct_name WithoutId>] {
|
impl [<$struct_name WithoutId>] {
|
||||||
pub fn into_full(self, id: $id_type) -> $struct_name {
|
pub fn into_full(self, id: $id_type) -> $struct_name {
|
||||||
$struct_name {
|
$struct_name {
|
||||||
$($field_name : self.$field_name,)*
|
|
||||||
id,
|
id,
|
||||||
|
$($(#[cfg($($cfgtt)*)])* $field_name : self.$field_name,)*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue