From c14dcf1998f5ba1ffea813da4f793fc3bde8c2b7 Mon Sep 17 00:00:00 2001 From: tom barrett Date: Mon, 26 Feb 2018 08:51:08 -0600 Subject: -figured out way to deserialize using serde_erased --- src/ship.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/ship.rs') diff --git a/src/ship.rs b/src/ship.rs index e5186c8..078c2c1 100644 --- a/src/ship.rs +++ b/src/ship.rs @@ -1,10 +1,11 @@ -use mass::Mass; +use mass::{Mass, Type}; extern crate serde_json; #[derive(Serialize, Deserialize, Debug)] pub struct Ship { name : String, location : (f64, f64, f64), + t : Type, r : f64, } @@ -19,6 +20,7 @@ impl Mass for Ship { Ship { name : String::from(name), location : location, + t : Type::Ship, r : 100.0, } } @@ -35,11 +37,7 @@ impl Mass for Ship { self.location = location; } - fn serialize(&self) ->String { + fn serialize(&self) -> String { serde_json::to_string(self).unwrap() } - - fn deserialize(&mut self, data : &str) { - //self = serde_json::from_str(data).unwrap(); - } } -- cgit v1.2.3