I'm trying to derive Deserialize on a struct that has borrowed content:
#[macro_use]
extern crate serde_derive;
use std::net::SocketAddr;
#[derive(Hash, Eq, PartialEq, Debug, Clone, Serialize, Deserialize)]
pub struct MyS<'a> {
pub addr: &'a SocketAddr,
}
I get the following compilation error:
error[E0277]: the trait bound `&'a std::net::SocketAddr: _::_serde::Deserialize<'_>` is not satisfied
--> src/lib.rs:7:5
|
7 | pub addr: &'a SocketAddr,
| ^^^ the trait `_::_serde::Deserialize<'_>` is not implemented for `&'a std::net::SocketAddr`
|
= help: the following implementations were found:
<std::net::SocketAddr as _::_serde::Deserialize<'de>>
= note: required by `_::_serde::de::SeqAccess::next_element`
What are the different ways I can get this struct to implement Deserialize for some lifetime ?
Note: I don't actually require the deserialization to be zero-copy, it's only a nice-to-have