mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-13 07:51:03 +00:00
Rename visit_enum_simple to visit_newtype_variant
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user