Please explain the Serde rc
feature
Opt into impls for
Rc<T>
andArc<T>
. Serializing and deserializing these types does not preserve identity and may result in multiple copies of the same data. Be sure that this is what you want before enabling this feature.Serializing a data structure containing reference-counted pointers will serialize a copy of the inner value of the pointer each time a pointer is referenced within the data structure. Serialization will not attempt to deduplicate these repeated data.
Deserializing a data structure containing reference-counted pointers will not attempt to deduplicate references to the same data. Every deserialized pointer will end up with a strong count of 1.
Why does this feature flag exist and why isn't it default behaviour? What does it mean by
Serializing and deserializing these types does not preserve identity and may result in multiple copies of the same data
I know that it is related to Serde issue 194. The last message of the issue says
If you want to make sure you don't accidentally end up with a derived impl containing an rc, open a clippy issue.
Does the feature flag exist to catch unexpected usages of an Rc
struct?