Hi,
This is some question about generics and if there is an advanced use case for this.
I am writing an API wrapper that is returning either a Vec<T>
or T
based on input.
I know that I could be using enums for the return type, yet wondering if there is any other way to do it. It is kind of an annoyance that the API returns either of both based on input, but here we are.
async fn request_some_api_endpoint(x:Option<&str>) -> <T, Error> {
// ... reqwest and deserialize
// deserialize uses [#serde untagged] to match Enum for T or Vec<T>
}
So if option of x is None, could T
become a Vec<T>
?