Skip to content

Associated types of TryFuture and TryStream #1090

@MajorBreakfast

Description

@MajorBreakfast

Currently we have:

pub trait Future { type Output; ... }
pub trait TryFuture { type Item; type Error; ... }
pub trait Stream { type Item; ... }
pub trait TryStream { type TryItem; type TryError; ... }
  • TryStream's success associated type cannot be called Item because Stream already uses that name for its associated type. That's why we end up with the not so great names TryItem and TryError
  • TryFuture and TryStream have inconsistently named associated types

Here's what I propose:

pub trait Future { type Output; ... }
pub trait TryFuture { type Ok; type Err; ... }
pub trait Stream { type Item; ... }
pub trait TryStream { type Ok; type Err; ... }

That way the naming would be consistent with the variants of the Result enum!

Future<Output = Result<T, E>>
TryFuture<Ok = T, Err = E>
Stream<Item = Result<T, E>>
TryStream<Ok = T, Err = E>

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