-
Notifications
You must be signed in to change notification settings - Fork 629
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
Rename (Trait, TraitExt) pairs to (TraitCore, Trait) #1398
Comments
The The |
Adding on to what @Matthias247 mentions, the "core" trait will still be heavily used in consumers. All generic APIs should be based on the core trait, and the extension is just brought into scope to provide extra methods on it. Because of that having the short name for the core trait is better since it will commonly be mentioned in multiple places per-file, while the extension trait will only ever be |
Closing-- the current design is intentional. |
In current API, most traits of futures-rs are splitted into 2 variants - one for implementors, and one for consumers. Formers are named without suffix, and latters are named with
Ext
suffix.Ironically those pair traits are mostly disjoint in usage pattern. For example, a library which expose a type that impls
Stream
doesn't need to know aboutStreamExt
trait in their code at all. And if I want to write a binary with heavy business logic, I don't want to care aboutpoll_next()
method so will only useStreamExt
trait.But in practice, there's way more library consumers than library writers, so most users only need
StreamExt
notStream
. I can easily imagin SO questions like "How can Imap
orfilter
onStream
type?" and correct answer for it is to replaceuse futures::stream::Stream
withfutures::stream::StreamExt
. Of course we can recommend touse futures::prelude::*
but some of them will complain about it as we all know the use-all pattern is considered bad in general.That's why I'm suggesting here to remove suffix from consumer-side traits. The
Core
suffix I referred in title needs more bikeshedding though.This issue is more like a RFC but I couldn't find a better place for it. Please let me know if this is not a right place for it!
The text was updated successfully, but these errors were encountered: