-
-
Notifications
You must be signed in to change notification settings - Fork 890
Closed
Labels
Description
I want to declare a generic struct with de-serialization but I don't know how to correctly require a Deserialize trait to be implemented for a generic type.
#[derive(Debug, Clone, Deserialize)]
pub struct Response<ResponseResult: Deserialize> {
/// some fields ...
pub result: ResponseResult,
}
Gives the error:
error[E0106]: missing lifetime specifier
--> src/model.rs:43:37
|
43 | pub struct Response<ResponseResult: Deserialize> {
| ^^^^^^^^^^^^^^ expected lifetime parameter
I understand that Deserialize trait requires a lifetime but I don't know how to specialize it right here. Is there a way?
Reactions are currently unavailable