-
I updated from actix-3.3 to 4.0.0-beta.3 (because I desperately need the Tokio v1) and my code (expectedly) has been broken. for example if I do
Where #[derive(Serialize)]
pub struct VerificationCheckResponse {
verified: bool
} I get HttpResponse::Ok().json(VerificationCheckResponse{
| ____________________________________^
56 | | verified: user.email_verified
57 | | })
| |_____^ the trait `Deref` is not implemented for `VerificationCheckResponse` I checked the actix-http code and found pub fn json<T: Serialize>(&mut self, value: T) -> Response {...} to pub fn json<T>(&mut self, value: T) -> Response
where
T: ops::Deref,
T::Target: Serialize,
{...} It doesn't seem right for us to implement Deref for every struct we wish to return as a basic JSON, also it seriously hurts developer QoL and overall ergonomics of the framework if it is intentional (imo, ofc). So, is this intentional? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The easy fix is to just pass While the change to take |
Beta Was this translation helpful? Give feedback.
The easy fix is to just pass
&VerificationCheckResponse {...}
.While the change to take
T: ops::Deref
was intentional, it was deemed slightly better to use a simpler approach and impl Serialize in more of our own structs for better DX. See #2052.