mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-12 23:41:03 +00:00
Improve wording of PR 2805 comments
This commit is contained in:
+16
-12
@@ -1904,12 +1904,13 @@ mod content {
|
|||||||
Content::None => visitor.visit_none(),
|
Content::None => visitor.visit_none(),
|
||||||
Content::Some(ref v) => visitor.visit_some(ContentRefDeserializer::new(v)),
|
Content::Some(ref v) => visitor.visit_some(ContentRefDeserializer::new(v)),
|
||||||
Content::Unit => visitor.visit_unit(),
|
Content::Unit => visitor.visit_unit(),
|
||||||
// This case is necessary for formats which does not store
|
// This case is to support data formats which do not encode an
|
||||||
// marker of optionality of value, for example, JSON. When
|
// indication whether a value is optional. An example of such a
|
||||||
// `deserialize_any` is requested from such formats, they will
|
// format is JSON, and a counterexample is RON. When requesting
|
||||||
// report value without using `Visitor::visit_some`, because
|
// `deserialize_any` in JSON, the data format never performs
|
||||||
// they do not known in which contexts this value will be used.
|
// `Visitor::visit_some` but we still must be able to
|
||||||
// RON is example of format which preserve markers.
|
// deserialize the resulting Content into data structures with
|
||||||
|
// optional fields.
|
||||||
_ => visitor.visit_some(self),
|
_ => visitor.visit_some(self),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1945,12 +1946,15 @@ mod content {
|
|||||||
Content::Newtype(ref v) => {
|
Content::Newtype(ref v) => {
|
||||||
visitor.visit_newtype_struct(ContentRefDeserializer::new(v))
|
visitor.visit_newtype_struct(ContentRefDeserializer::new(v))
|
||||||
}
|
}
|
||||||
// This case is necessary for formats which does not store
|
// This case is to support data formats that encode newtype
|
||||||
// marker of a newtype, for example, JSON. When
|
// structs and their underlying data the same, with no
|
||||||
// `deserialize_any` is requested from such formats, they will
|
// indication whether a newtype wrapper was present. For example
|
||||||
// report value without using `Visitor::visit_newtype_struct`,
|
// JSON does this, while RON does not. In RON a newtype's name
|
||||||
// because they do not known in which contexts this value will
|
// is included in the serialized representation and it knows to
|
||||||
// be used. RON is example of format which preserve markers.
|
// call `Visitor::visit_newtype_struct` from `deserialize_any`.
|
||||||
|
// JSON's `deserialize_any` never calls `visit_newtype_struct`
|
||||||
|
// but in this code we still must be able to deserialize the
|
||||||
|
// resulting Content into newtypes.
|
||||||
_ => visitor.visit_newtype_struct(self),
|
_ => visitor.visit_newtype_struct(self),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user