I just want to make a little REST API client but apparently I have to master Rust lifetimes before I can deserialize some JSON

I keep ping ponging between "Rust is neat and I like doing this" to "how does anyone get anything done in Rust"


Had to put this down for awhile and come back with a clean head (can't spell "frustrating" without "rust"), but this finally works and now I can build higher-level API wrappers around this primitive.

· · Web · 1 · 0 · 1

@stevestreza my rust code still uses things like DeserializeOwned because I’m never sure if I can even figure out the lifetime situation of the alternative.

@jfro I might be complicating the situation by decoding to a generic container, but yeah I have no idea what the difference is. My best guess is that Deserialize does a move and DeserializeOwned does a copy/clone, and performance-sensitive apps might want zero-copy behavior?

@stevestreza yeah DeserializeOwned makes it so you can just keep things simple and your decodes types have things like String instead of say &str. I haven’t tried at all to do the non owned way. But yeah imagine it’d be good if you need to avoid copies/allocations

Sign in to participate in the conversation

The original server operated by the Mastodon gGmbH non-profit