refactor(upgrade): explicitly specify type parameter in downcast method#3913
refactor(upgrade): explicitly specify type parameter in downcast method#39131911860538 wants to merge 1 commit intohyperium:masterfrom
Conversation
|
Thanks for the PR! What motivated this change? I think the original code is pretty clear and impossible for inference to mess up... |
|
|
Hm, ok. I lean towards leaving it alone, but if another reviewer feels differently, I could be swayed. @hyperium/triage |
😂 |
| pub fn downcast<T: Read + Write + Unpin + 'static>(self) -> Result<Parts<T>, Self> { | ||
| let (io, buf) = self.io.into_inner(); | ||
| match io.__hyper_downcast() { | ||
| match io.__hyper_downcast::<T>() { |
There was a problem hiding this comment.
usually, the convention i am familiar with is to rely on "turbofish" syntax like this when the type parameter is ambiguous, and a specific concrete type must be provided. for example, iter.collect::<Vec<_>>().
my disposition is also to leave this call as is.
Make the type parameter passing more explicit by changing
io.__hyper_downcast()toio.__hyper_downcast::<T>()in thedowncast method. This improves code clarity and avoids potential
type inference ambiguities in multi-generic scenarios.