Rename visit_enum_simple to visit_newtype_variant

This commit is contained in:
Erick Tryzelaar committed 2015-07-31 07:22:13 -07:00
1 parent 6cbb72decf
commit fefc010deb
6 files changed
+31 -31

No files matched your search

+2 -2
View File
@@ -632,10 +632,10 @@ impl<T, E> Serialize for Result<T, E> where T: Serialize, E: Serialize {
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error> where S: Serializer {
match *self {
Result::Ok(ref value) => {
serializer.visit_enum_simple("Result", 0, "Ok", value)
serializer.visit_newtype_variant("Result", 0, "Ok", value)
}
Result::Err(ref value) => {
serializer.visit_enum_simple("Result", 1, "Err", value)
serializer.visit_newtype_variant("Result", 1, "Err", value)
}
}
}
+8 -5
View File
@@ -125,12 +125,15 @@ pub trait Serializer {
self.visit_unit()
}
/// The `visit_newtype_variant` allows a variant with a single item to be more efficiently
/// serialized than a variant with multiple items. By default it just serializes the value as a
/// tuple variant sequence.
#[inline]
fn visit_enum_simple<T>(&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str,
value: T) -> Result<(), Self::Error>
fn visit_newtype_variant<T>(&mut self,
name: &'static str,
variant_index: usize,
variant: &'static str,
value: T) -> Result<(), Self::Error>
where T: Serialize,
{
self.visit_tuple_variant(