This fascinating snippet of Rust does some tricky work with no allocations or copying, type- and memory-safely: gist.github.com/Aatch/5734372
Conversation
it at least allocates the Some() on line 59, right? Very cool, though.
1
Replying to
Ah, sorry, I wasn’t counting stack allocations because they’re not what I normally worry about. Yes.
Replying to
hm, how does that Some avoid being heap allocated? It gets returned from the get_string call. (I don't know Rust well).
1
The Some wraps a reference to an inner pointer of the json argument. The “lifetime parameters” ensure the safety of that trick.
1
Show replies

