(This is not super surprising when you think about it, but it bit me recently so I figured I’d write it up.)

TL;DR: Be careful when using &'a str or &'a [u8] with serde deserializers; serde has no way to produce an appropriate compile-time error when zero-copy deserialization isn’t possible or just isn’t supported. Instead, you’ll get a runtime error indefinitely later.

serde is Rust’s de facto standard serialization/deserialization framework. It’s also arguably one of the "crown jewels" of the Rust ecosystem, insofar as it’s broadly used and solves a thorny ergonomics problem (corresponding the serialized representation of a structure to its type) without imposting format-specific constraints on the types themselves1.

serde also has a deg…

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help