Skip to content

refactor(upgrade): explicitly specify type parameter in downcast method #3913

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

1911860538
Copy link

Make the type parameter passing more explicit by changing
io.__hyper_downcast() to io.__hyper_downcast::<T>() in the
downcast method. This improves code clarity and avoids potential
type inference ambiguities in multi-generic scenarios.

@seanmonstar
Copy link
Member

Thanks for the PR! What motivated this change? I think the original code is pretty clear and impossible for inference to mess up...

@1911860538
Copy link
Author

Thanks for the PR! What motivated this change? I think the original code is pretty clear and impossible for inference to mess up...

Yes, because this method has only one generic parameter, the original code is impossible to encounter type inference issues. My modification primarily aims to enhance readability. Improved code clarity is achieved as explicit type parameters clearly indicate the target downcast type, making the code more readable and self-documenting.

@seanmonstar
Copy link
Member

Hm, ok. I lean towards leaving it alone, but if another reviewer feels differently, I could be swayed. @hyperium/triage

@1911860538
Copy link
Author

Hm, ok. I lean towards leaving it alone, but if another reviewer feels differently, I could be swayed. @hyperium/triage

😂

match io.__hyper_downcast() {
match io.__hyper_downcast::<T>() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants