serde impl #16
Generated
+4
-2
@@ -152,6 +152,8 @@ dependencies = [
|
|||||||
"card_game",
|
"card_game",
|
||||||
"klondike",
|
"klondike",
|
||||||
"rand",
|
"rand",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -266,9 +268,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_json"
|
name = "serde_json"
|
||||||
version = "1.0.149"
|
version = "1.0.150"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86"
|
checksum = "e8014e44b4736ed0538adeecded0fce2a272f22dc9578a7eb6b2d9993c74cfb9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itoa",
|
"itoa",
|
||||||
"memchr",
|
"memchr",
|
||||||
|
|||||||
@@ -8,5 +8,9 @@ card_game.workspace = true
|
|||||||
klondike.workspace = true
|
klondike.workspace = true
|
||||||
rand = { version = "0.10.1", default-features = false, features = ["thread_rng"] }
|
rand = { version = "0.10.1", default-features = false, features = ["thread_rng"] }
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
serde = { version = "1.0.228", default-features = false }
|
||||||
|
serde_json = "1.0.150"
|
||||||
|
|
||||||
[lints]
|
[lints]
|
||||||
workspace = true
|
workspace = true
|
||||||
|
|||||||
@@ -14,3 +14,16 @@ fn test_is_winnable() {
|
|||||||
println!("Game is not winnable");
|
println!("Game is not winnable");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_serde() {
|
||||||
|
let mut session = Session::new_default(Klondike::with_seed(124));
|
||||||
|
let solution_result = session.solve();
|
||||||
|
if let Ok(Some(solution)) = solution_result {
|
||||||
|
for snapshot in solution.clean_solution() {
|
||||||
|
session.process_instruction(snapshot.instruction().clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let serialized = serde_json::to_string(&session).unwrap();
|
||||||
|
println!("serialized = {serialized}");
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user