Where did the DeserializeOwned trait go in serde?


I am trying to write a function that returns something deserialized so I cannot use deserialize since the thing I read from the file does not outlive the function. But I cannot find the deserialized owned trait in serde.
here are the available traits
and here serde mentions about the nonexistent deserialize owned trait.
So if it’s removed what to use instead and why would they want to remove that?


I think that’s the one.


it looks confusing. Why do you think they named it like this?


From what I see, Serde has two modules, “ser” where you have everything related to serialization and “de” for deserialization.
When you go to the doc index you only have 4 traits, they have been re-exported. It’s common to re-export to the root of a crate what is used really often and/or provide a simple way to use the crate. If you want “more advanced” features, you can explore the modules.
It’s not a rule but many crates work like that.


I wish this practice was more common, frankly. The public module tree should be curated separately from the internal organization of the crate. But a lot of crates just expose their module heirarchy publically (cough). Frunk used to be like this until I had a go at it (and in large, it still is).

For instance, rayon could do with having a number of the things in iter reexported from the root. In this case, rayon has a bit of an excuse due to its prelude, but I feel that IntoParallelIterator belongs both in the prelude and the root.

Basically, the way I feel is that, with few exceptions (e.g. frunk::labelled::chars), something should be imported by name if it is used by name. So I am fine with

use rayon::prelude::*;


But if I wanted to impl the trait, I’d rather import it by name. That’s where flattening the namespace a bit would make it more user-friendly.

use rayon::iter::IntoParallelIterator;

struct Struct(Vec<u8>);

impl IntoParallelIterator for Struct {