Skip to content

SinkExt::with or SinkExt::map for non-async functions #2963

@lehmanju

Description

@lehmanju

To map the Item of a Sink I currently use:

let sink: Sink<Item = OldItemType> = ...;
let mapped_sink: Sink<Item = NewItemType> = pin!(sink.with(|value: NewItemType| async {  value.into() }));

Since the closure doesn't need to be async, I'd like to have something like StreamExt::map which takes FnMut instead. This would also make writing pin! obsolete which is necessary because anonymous async closures are !Unpin.

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