Be Careful Zero-Copying Strings with serde

When deserializing a string using serde , it is possible to use a borrowed &str instead of an owned String : use serde :: Deserialize ; use serde_json ; # [ derive ( Deserialize ) ] struct Foo < ' a > { &#x2F;&#x2F; This string is borrowed. text : & ' a str , } fn main ( ) { let json = r # " { "text": "Hello, world!" } " # ; let foo : Foo = serde_json :: from_str ( json ) . unwrap ( ) ; println! (…