Skip to content

Analogue of .last() method #2822

Open
Open
@xamgore

Description

@xamgore

I'd like to run FuturesOrdered::from_iter(...) and retrieve the result of the last element, which is Option<...>. The same function exists in std.

It can be implemented with

iter.fold(None, |_acc, x| async move { Some(x) })

But try_last would require extra checks: if there is an intermediate error, return it. If not, return the last successful Ok(...).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions