Skip to content

Rename (Trait, TraitExt) pairs to (TraitCore, Trait) #1398

Closed
@HyeonuPark

Description

@HyeonuPark

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 about StreamExt trait in their code at all. And if I want to write a binary with heavy business logic, I don't want to care about poll_next() method so will only use StreamExt trait.

But in practice, there's way more library consumers than library writers, so most users only need StreamExt not Stream. I can easily imagin SO questions like "How can I map or filter on Stream type?" and correct answer for it is to replace use futures::stream::Stream with futures::stream::StreamExt. Of course we can recommend to use 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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions