From f43e2e13c75c64a88ca04157f33716b1dd5472ec Mon Sep 17 00:00:00 2001 From: Andrew Dudney Date: Tue, 23 Aug 2016 12:23:07 -0600 Subject: [PATCH] Converted serde serialization to new style --- src/transform.rs | 40 +++++----------------------------------- 1 file changed, 5 insertions(+), 35 deletions(-) diff --git a/src/transform.rs b/src/transform.rs index 83db3f2..53bff7f 100644 --- a/src/transform.rs +++ b/src/transform.rs @@ -197,41 +197,11 @@ mod eders_ser { fn serialize(&self, serializer: &mut S) -> Result<(), S::Error> where S: serde::Serializer { - serializer.serialize_struct("Decomposed", DecomposedVisitor { - value: self, - state: 0, - }) - } - } - - struct DecomposedVisitor<'a, V: 'a + VectorSpace, R: 'a> { - value: &'a Decomposed, - state: u8, - } - - impl<'a, V: 'a + VectorSpace, R> serde::ser::MapVisitor for DecomposedVisitor<'a, V, R> - where V: Serialize, V::Scalar: Serialize, R: Serialize - { - fn visit(&mut self, serializer: &mut S) -> Result, S::Error> - where S: serde::Serializer - { - match self.state { - 0 => { - self.state += 1; - Ok(Some(try!(serializer.serialize_struct_elt("scale", &self.value.scale)))) - }, - 1 => { - self.state += 1; - Ok(Some(try!(serializer.serialize_struct_elt("rot", &self.value.rot)))) - }, - 2 => { - self.state += 1; - Ok(Some(try!(serializer.serialize_struct_elt("disp", &self.value.disp)))) - }, - _ => { - Ok(None) - }, - } + let mut state = try!(serializer.serialize_struct("Decomposed", 3)); + try!(serializer.serialize_struct_elt(&mut state, "scale", &self.scale)); + try!(serializer.serialize_struct_elt(&mut state, "rot", &self.rot)); + try!(serializer.serialize_struct_elt(&mut state, "disp", &self.disp)); + serializer.serialize_struct_end(state) } } }