move macro to convert mod

This commit is contained in:
Dmitry Belyaev 2023-08-06 00:11:44 +03:00
parent 0c0a4e31ba
commit 150527efeb
1 changed files with 9 additions and 10 deletions

View File

@ -1,14 +1,5 @@
use serde_derive::{Deserialize, Serialize};
macro_rules! make {
($Target:ident; by {$($field:ident),+}; from $src:expr) => {$Target {$(
$field: $src.$field
),+}};
($Target:ident; with defaults and by {$($field:ident),+}; from $src:expr) => {$Target {$(
$field: $src.$field
),+ ,..$Target::default()}}
}
#[derive(Debug, Default, Clone, Serialize, Deserialize, bincode::Decode, bincode::Encode)]
pub struct BatchInfo {
#[serde(default)]
@ -80,9 +71,17 @@ pub struct Question {
#[cfg(feature = "source")]
pub mod convert {
use super::{BatchInfo, Question};
use crate::source::{SourceQuestion, SourceQuestionsBatch};
use super::{BatchInfo, Question};
macro_rules! make {
($Target:ident; by {$($field:ident),+}; from $src:expr) => {$Target {$(
$field: $src.$field
),+}};
($Target:ident; with defaults and by {$($field:ident),+}; from $src:expr) => {$Target {$(
$field: $src.$field
),+ ,..$Target::default()}}
}
impl From<SourceQuestion> for Question {
fn from(src: SourceQuestion) -> Self {