diff --git a/serde/src/ser/impls.rs b/serde/src/ser/impls.rs index 3de53ebe..1d9205ab 100644 --- a/serde/src/ser/impls.rs +++ b/serde/src/ser/impls.rs @@ -169,9 +169,9 @@ impl Serialize for [T] { let mut seq = try!(serializer.serialize_seq(Some(self.len()))); for e in self { - try!(seq.serialize_elem(e)); + try!(seq.serialize_element(e)); } - seq.serialize_end() + seq.end() } } @@ -186,9 +186,9 @@ macro_rules! array_impls { { let mut seq = try!(serializer.serialize_seq_fixed_size($len)); for e in self { - try!(seq.serialize_elem(e)); + try!(seq.serialize_element(e)); } - seq.serialize_end() + seq.end() } } } @@ -249,9 +249,9 @@ impl<'a, I> Serialize for Iterator }; let mut seq = try!(serializer.serialize_seq(size)); for e in iter { - try!(seq.serialize_elem(e)); + try!(seq.serialize_element(e)); } - seq.serialize_end() + seq.end() } } @@ -265,9 +265,9 @@ macro_rules! serialize_seq { { let mut seq = try!(serializer.serialize_seq(Some(self.len()))); for e in self { - try!(seq.serialize_elem(e)); + try!(seq.serialize_element(e)); } - seq.serialize_end() + seq.end() } } } @@ -334,9 +334,9 @@ impl Serialize for ops::Range let len = iter::Step::steps_between(&self.start, &self.end, &A::one()); let mut seq = try!(serializer.serialize_seq(len)); for e in self.clone() { - try!(seq.serialize_elem(e)); + try!(seq.serialize_element(e)); } - seq.serialize_end() + seq.end() } } @@ -369,9 +369,9 @@ macro_rules! tuple_impls { { let mut tuple = try!(serializer.serialize_tuple($len)); $( - try!(tuple.serialize_elem(&self.$idx)); + try!(tuple.serialize_element(&self.$idx)); )+ - tuple.serialize_end() + tuple.end() } } )+ @@ -562,7 +562,7 @@ macro_rules! serialize_map { try!(map.serialize_key(k)); try!(map.serialize_value(v)); } - map.serialize_end() + map.end() } } } @@ -682,7 +682,7 @@ impl Serialize for Duration { let mut state = try!(serializer.serialize_struct("Duration", 2)); try!(state.serialize_field("secs", self.as_secs())); try!(state.serialize_field("nanos", self.subsec_nanos())); - state.serialize_end() + state.end() } } diff --git a/serde/src/ser/mod.rs b/serde/src/ser/mod.rs index aa19f362..3b2e3d34 100644 --- a/serde/src/ser/mod.rs +++ b/serde/src/ser/mod.rs @@ -183,9 +183,9 @@ pub trait Serializer { /// ```rust /// let mut seq = self.serialize_seq(Some(value.len()))?; /// for b in value { - /// seq.serialize_elem(b)?; + /// seq.serialize_element(b)?; /// } - /// seq.serialize_end() + /// seq.end() /// ``` fn serialize_bytes(self, value: &[u8]) -> Result; @@ -324,10 +324,10 @@ pub trait SerializeSeq { type Error: Error; /// Serializes a sequence element. - fn serialize_elem(&mut self, value: T) -> Result<(), Self::Error>; + fn serialize_element(&mut self, value: T) -> Result<(), Self::Error>; /// Finishes serializing a sequence. - fn serialize_end(self) -> Result; + fn end(self) -> Result; } /// Returned from `Serializer::serialize_tuple`. @@ -340,10 +340,10 @@ pub trait SerializeTuple { type Error: Error; /// Serializes a tuple element. - fn serialize_elem(&mut self, value: T) -> Result<(), Self::Error>; + fn serialize_element(&mut self, value: T) -> Result<(), Self::Error>; /// Finishes serializing a tuple. - fn serialize_end(self) -> Result; + fn end(self) -> Result; } /// Returned from `Serializer::serialize_tuple_struct`. @@ -356,10 +356,10 @@ pub trait SerializeTupleStruct { type Error: Error; /// Serializes a tuple struct element. - fn serialize_elem(&mut self, value: T) -> Result<(), Self::Error>; + fn serialize_field(&mut self, value: T) -> Result<(), Self::Error>; /// Finishes serializing a tuple struct. - fn serialize_end(self) -> Result; + fn end(self) -> Result; } /// Returned from `Serializer::serialize_tuple_variant`. @@ -372,10 +372,10 @@ pub trait SerializeTupleVariant { type Error: Error; /// Serializes a tuple variant element. - fn serialize_elem(&mut self, value: T) -> Result<(), Self::Error>; + fn serialize_field(&mut self, value: T) -> Result<(), Self::Error>; /// Finishes serializing a tuple variant. - fn serialize_end(self) -> Result; + fn end(self) -> Result; } /// Returned from `Serializer::serialize_map`. @@ -394,7 +394,7 @@ pub trait SerializeMap { fn serialize_value(&mut self, value: T) -> Result<(), Self::Error>; /// Finishes serializing a map. - fn serialize_end(self) -> Result; + fn end(self) -> Result; } /// Returned from `Serializer::serialize_struct`. @@ -410,7 +410,7 @@ pub trait SerializeStruct { fn serialize_field(&mut self, key: &'static str, value: V) -> Result<(), Self::Error>; /// Finishes serializing a struct. - fn serialize_end(self) -> Result; + fn end(self) -> Result; } /// Returned from `Serializer::serialize_struct_variant`. @@ -426,7 +426,7 @@ pub trait SerializeStructVariant { fn serialize_field(&mut self, key: &'static str, value: V) -> Result<(), Self::Error>; /// Finishes serializing a struct variant. - fn serialize_end(self) -> Result; + fn end(self) -> Result; } /// A wrapper type for iterators that implements `Serialize` for iterators whose items implement diff --git a/serde_codegen/src/ser.rs b/serde_codegen/src/ser.rs index 8f36e0ce..acd9973c 100644 --- a/serde_codegen/src/ser.rs +++ b/serde_codegen/src/ser.rs @@ -159,7 +159,7 @@ fn serialize_tuple_struct( fields, impl_generics, false, - quote!(_serde::ser::SerializeTupleStruct::serialize_elem), + quote!(_serde::ser::SerializeTupleStruct::serialize_field), ); let type_name = item_attrs.name().serialize_name(); @@ -169,7 +169,7 @@ fn serialize_tuple_struct( quote! { let #let_mut __serde_state = try!(_serializer.serialize_tuple_struct(#type_name, #len)); #(#serialize_stmts)* - _serde::ser::SerializeTupleStruct::serialize_end(__serde_state) + _serde::ser::SerializeTupleStruct::end(__serde_state) } } @@ -210,7 +210,7 @@ fn serialize_struct( quote! { let #let_mut __serde_state = try!(_serializer.serialize_struct(#type_name, #len)); #(#serialize_fields)* - _serde::ser::SerializeStruct::serialize_end(__serde_state) + _serde::ser::SerializeStruct::end(__serde_state) } } @@ -373,7 +373,7 @@ fn serialize_tuple_variant( fields, generics, true, - quote!(_serde::ser::SerializeTupleVariant::serialize_elem), + quote!(_serde::ser::SerializeTupleVariant::serialize_field), ); let len = serialize_stmts.len(); @@ -386,7 +386,7 @@ fn serialize_tuple_variant( #variant_name, #len)); #(#serialize_stmts)* - _serde::ser::SerializeTupleVariant::serialize_end(__serde_state) + _serde::ser::SerializeTupleVariant::end(__serde_state) } } @@ -433,7 +433,7 @@ fn serialize_struct_variant( #len, )); #(#serialize_fields)* - _serde::ser::SerializeStructVariant::serialize_end(__serde_state) + _serde::ser::SerializeStructVariant::end(__serde_state) } } @@ -558,7 +558,7 @@ fn wrap_serialize_with( // Serialization of an empty struct results in code like: // // let mut __serde_state = try!(serializer.serialize_struct("S", 0)); -// _serde::ser::SerializeStruct::serialize_end(__serde_state) +// _serde::ser::SerializeStruct::end(__serde_state) // // where we want to omit the `mut` to avoid a warning. fn mut_if(is_mut: bool) -> Option { diff --git a/serde_test/src/ser.rs b/serde_test/src/ser.rs index 85af06e0..60c50125 100644 --- a/serde_test/src/ser.rs +++ b/serde_test/src/ser.rs @@ -228,14 +228,14 @@ impl<'s, 'a, I> ser::SerializeSeq for &'s mut Serializer<'a, I> type Ok = (); type Error = Error; - fn serialize_elem(&mut self, value: T) -> Result<(), Error> + fn serialize_element(&mut self, value: T) -> Result<(), Error> where T: Serialize { assert_eq!(self.tokens.next(), Some(&Token::SeqSep)); value.serialize(&mut **self) } - fn serialize_end(self) -> Result<(), Error> { + fn end(self) -> Result<(), Error> { assert_eq!(self.tokens.next(), Some(&Token::SeqEnd)); Ok(()) } @@ -247,14 +247,14 @@ impl<'s, 'a, I> ser::SerializeTuple for &'s mut Serializer<'a, I> type Ok = (); type Error = Error; - fn serialize_elem(&mut self, value: T) -> Result<(), Error> + fn serialize_element(&mut self, value: T) -> Result<(), Error> where T: Serialize { assert_eq!(self.tokens.next(), Some(&Token::TupleSep)); value.serialize(&mut **self) } - fn serialize_end(self) -> Result<(), Error> { + fn end(self) -> Result<(), Error> { assert_eq!(self.tokens.next(), Some(&Token::TupleEnd)); Ok(()) } @@ -266,14 +266,14 @@ impl<'s, 'a, I> ser::SerializeTupleStruct for &'s mut Serializer<'a, I> type Ok = (); type Error = Error; - fn serialize_elem(&mut self, value: T) -> Result<(), Error> + fn serialize_field(&mut self, value: T) -> Result<(), Error> where T: Serialize { assert_eq!(self.tokens.next(), Some(&Token::TupleStructSep)); value.serialize(&mut **self) } - fn serialize_end(self) -> Result<(), Error> { + fn end(self) -> Result<(), Error> { assert_eq!(self.tokens.next(), Some(&Token::TupleStructEnd)); Ok(()) } @@ -285,14 +285,14 @@ impl<'s, 'a, I> ser::SerializeTupleVariant for &'s mut Serializer<'a, I> type Ok = (); type Error = Error; - fn serialize_elem(&mut self, value: T) -> Result<(), Error> + fn serialize_field(&mut self, value: T) -> Result<(), Error> where T: Serialize { assert_eq!(self.tokens.next(), Some(&Token::EnumSeqSep)); value.serialize(&mut **self) } - fn serialize_end(self) -> Result<(), Error> { + fn end(self) -> Result<(), Error> { assert_eq!(self.tokens.next(), Some(&Token::EnumSeqEnd)); Ok(()) } @@ -313,7 +313,7 @@ impl<'s, 'a, I> ser::SerializeMap for &'s mut Serializer<'a, I> value.serialize(&mut **self) } - fn serialize_end(self) -> Result<(), Self::Error> { + fn end(self) -> Result<(), Self::Error> { assert_eq!(self.tokens.next(), Some(&Token::MapEnd)); Ok(()) } @@ -331,7 +331,7 @@ impl<'s, 'a, I> ser::SerializeStruct for &'s mut Serializer<'a, I> value.serialize(&mut **self) } - fn serialize_end(self) -> Result<(), Self::Error> { + fn end(self) -> Result<(), Self::Error> { assert_eq!(self.tokens.next(), Some(&Token::StructEnd)); Ok(()) } @@ -349,7 +349,7 @@ impl<'s, 'a, I> ser::SerializeStructVariant for &'s mut Serializer<'a, I> value.serialize(&mut **self) } - fn serialize_end(self) -> Result<(), Self::Error> { + fn end(self) -> Result<(), Self::Error> { assert_eq!(self.tokens.next(), Some(&Token::EnumMapEnd)); Ok(()) }