How do I serialize or deserialize an Arc in Serde?

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> and Arc<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"] }

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)