move macro to convert mod
This commit is contained in:
parent
0c0a4e31ba
commit
150527efeb
@ -1,14 +1,5 @@
|
|||||||
use serde_derive::{Deserialize, Serialize};
|
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)]
|
#[derive(Debug, Default, Clone, Serialize, Deserialize, bincode::Decode, bincode::Encode)]
|
||||||
pub struct BatchInfo {
|
pub struct BatchInfo {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
@ -80,9 +71,17 @@ pub struct Question {
|
|||||||
|
|
||||||
#[cfg(feature = "source")]
|
#[cfg(feature = "source")]
|
||||||
pub mod convert {
|
pub mod convert {
|
||||||
|
use super::{BatchInfo, Question};
|
||||||
use crate::source::{SourceQuestion, SourceQuestionsBatch};
|
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 {
|
impl From<SourceQuestion> for Question {
|
||||||
fn from(src: SourceQuestion) -> Self {
|
fn from(src: SourceQuestion) -> Self {
|
||||||
|
Loading…
Reference in New Issue
Block a user