Skip to content

Make Directory::iterate_dir version returning an Iterator #125

@orsinium

Description

@orsinium

In the current implementation, Directory::iterate_dir accepts a callback to be executed for each entry. Returning an Iterator instead could make working with it much easier:

  1. It would match std::fs::read_dir behavior.
  2. It would make it possible to stop the iteration at any point.
  3. It's easy to convert iterators to callbacks (using map method)
  4. It's hard to convert a callback into an iterator. Well, I don't currently see an easy way except pushing all entries from the callback into a vector, but that will require memory allocations.

Another well-known project to use iterators is embedded_graphics which proves that iterators are fast enough for use on embedded devices.

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