I have been looking at the API for this crate as someone relatively new to Rust.
Amongst the code, I noticed this method deceleration for the requests::Builder struct
pub fn method<T>(self, method: T) -> Builder
where
Method: TryFrom<T>,
<Method as TryFrom<T>>::Error: Into<Error>,
Initially I was confused as to the reasoning that a constraint on Method was defined here.
Since Method seems to be unused in the function signature.
After looking deeper I realize the point of this constraint is to limit T to values that can be converted to Method::try_from.
Is there any reason that the where clause doesn't use the reciprocal trait TryInto instead?
For example,
pub fn method<T>(self, method: T) -> Builder
where
T TryInto<Method>,
<T as TryInto<Method>>::Error: Into<Error>,
Idk about others but this would have been clearer to me.
I was curious if there was a reason as to why the original was chosen over this second solution, which I think is more clear(imo).
I have been looking at the API for this crate as someone relatively new to Rust.
Amongst the code, I noticed this method deceleration for the requests::Builder struct
Initially I was confused as to the reasoning that a constraint on
Methodwas defined here.Since
Methodseems to be unused in the function signature.After looking deeper I realize the point of this constraint is to limit
Tto values that can be converted toMethod::try_from.Is there any reason that the where clause doesn't use the reciprocal trait
TryIntoinstead?For example,
Idk about others but this would have been clearer to me.
I was curious if there was a reason as to why the original was chosen over this second solution, which I think is more clear(imo).