You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm designing an http api where every response is json and has diffferent fields depending on the api call, but always has a status and code field. I am acomplishing this through the Response struct:
In situations where I just want to return a status, I intended on constructing a Response<()>, but that gives me this error: thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error("can only flatten structs and maps (got unit)", line: 0, column: 0)', src/libcore/result.rs:1189:5
I expected that flattening a Unit would just add no fields. I could make a struct with no fields and make a Response<NoFields>, but that seems unidiomatic and requires adding an extra type that doesn't do anything. Is there a reason that you can't flatten a Unit?
The text was updated successfully, but these errors were encountered:
I'm designing an http api where every response is json and has diffferent fields depending on the api call, but always has a status and code field. I am acomplishing this through the Response struct:
In situations where I just want to return a status, I intended on constructing a
Response<()>
, but that gives me this error:thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error("can only flatten structs and maps (got unit)", line: 0, column: 0)', src/libcore/result.rs:1189:5
I expected that flattening a Unit would just add no fields. I could make a struct with no fields and make a
Response<NoFields>
, but that seems unidiomatic and requires adding an extra type that doesn't do anything. Is there a reason that you can't flatten a Unit?The text was updated successfully, but these errors were encountered: