serde derive failing on a struct with a reference field
I'm trying to #[derive(Deserialize)] on a struct that has a &'a str field. Error:
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
--> src/models.rs:19:10
|
19 | pub struct Record<'a> {
20 | pub name: &'a str,
| ^^^^
|
note: expected &'a str, found &str
I know I need #[serde(borrow)] somewhere but I can't get the syntax right with serde 1.0.197. What's the correct way to deserialize borrowed strings?
4 replies