servo / rust-smallvec

"Small vector" optimization for Rust: store up to a small number of items on the stack
Apache License 2.0
1.35k stars 145 forks source link

Unable to deserialize the non-owned structures #349

Closed MOZGIII closed 6 months ago

MOZGIII commented 6 months ago

I can't deserialize SmallVec<[&'static str; 5]>; as the code fails with the following:

error: lifetime may not live long enough
  --> .../src/lib.rs:33:5
   |
29 |   #[derive(Debug, Deserialize)]
   |                   ----------- lifetime `'de` defined here
...
33 | /     /// List of locales for the country.
34 | |     locales: SmallVec<[&'static str; 5]>,
   | |________________________^ requires that `'de` must outlive `'static`
MOZGIII commented 6 months ago

Nvm, my bad, had to use #[serde(borrow)]