Consider impl <T, R: Into<T>> IntoRequest<T> for R
- Dominant language
- Rust
- Stars
- 12.5k
- Forks
- 1.3k
- Avg merge
- 4d 7h
- Merged PRs (30d)
- 24
Description
## Feature Request
Tonic's client functions take `IntoRequest` for the request type. But if I have a type `R` that implements `Into`, I can't pass `my_r.into()` into the function because the type system won't figure out that I want the `.into()` for `T`.
If we'd have a generic implementation as below, we could pass an `R` object into the client method.
```rust
impl > IntoRequest for R {
fn into_request(self) -> Request {
T::from(self).into_request()
}
}
```
### Motivation
Simplifying calling client functions with custom structs that `Into` the protobuf requests. I think this is a common pattern. The protobuf messages use only the raw types, so often clients have structs with business logic types and then conversion `Into` and `TryFrom` implementations between business-logic structs and protobuf structs.
Contributor guide
Assessment
This issue has not been assessed yet.