Skip to content

How to use try_fold in place of fold_while? #469

@NoraCodes

Description

@NoraCodes

fold_while has been deprecated in favor of try_fold, and will eventually be removed ( #223 ). However, there is little documentation on how to actually do this in an idiomatic way.

For example, this playground comparison is the best I could do and it looks awful. The iterator finishing early isn't an error - it's a totally acceptable condition.

I'm sure there's a better way to do this, but it would be nice to document that in fold_while or, perhaps, in try_fold (I'll be happy to open a MR for that if someone can give me a good example.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions