move struct into deserialize impl
This commit is contained in:
+11
-14
@@ -653,20 +653,6 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
feature = "serde",
|
||||
derive(serde_derive::Deserialize),
|
||||
serde(bound(deserialize = "
|
||||
G: serde::Deserialize<'de>,
|
||||
SessionConfig<G::Config>: serde::Deserialize<'de>,
|
||||
Vec<G::Instruction>: serde::Deserialize<'de>,
|
||||
"))
|
||||
)]
|
||||
struct SerializedSession<G: Game> {
|
||||
config: SessionConfig<G::Config>,
|
||||
state: G,
|
||||
history: Vec<G::Instruction>,
|
||||
}
|
||||
#[cfg(feature = "serde")]
|
||||
impl<'de, G: Game<Score = i32>> serde::de::Deserialize<'de> for Session<G>
|
||||
where
|
||||
@@ -680,6 +666,17 @@ where
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
#[derive(serde_derive::Deserialize)]
|
||||
#[serde(bound(deserialize = "
|
||||
G: serde::Deserialize<'de>,
|
||||
SessionConfig<G::Config>: serde::Deserialize<'de>,
|
||||
Vec<G::Instruction>: serde::Deserialize<'de>,
|
||||
"))]
|
||||
struct SerializedSession<G: Game> {
|
||||
config: SessionConfig<G::Config>,
|
||||
state: G,
|
||||
history: Vec<G::Instruction>,
|
||||
}
|
||||
let serialized = SerializedSession::deserialize(deserializer)?;
|
||||
let mut session = Session::new(serialized.state, serialized.config);
|
||||
for instruction in serialized.history {
|
||||
|
||||
Reference in New Issue
Block a user