I have a struct that contains children of its own type. These children are wrapped in Arc
s, and I\'m getting issues when calling serde_json::to_string
Serde provides implementations of Serialize
and Deserialize
for Arc<T>
and Rc<T>
, but only if the rc
feature is enabled.
There's a comment on Serde's reference website explaining why:
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.
To enable the rc
feature, you need to ask for it in your own Cargo.toml
:
[dependencies]
serde = { version = "1.0", features = ["rc"] }