Skip to content

Document expected relationships between FromIterator, Default, and Extend #58659

@ExpHP

Description

@ExpHP

Somebody who creates a type that implements both Default and Extend should be aware that their type can be created through Iterator::unzip. In fact, any such type should probably also implement FromIterator, with the semantics that:

let mut a = TheType::default()
a.extend(iter);

is identical to iter.collect().

(I wonder why unzip didn't decide to use FromIterator + Extend instead?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-collectionsArea: `std::collections`A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsA-iteratorsArea: IteratorsC-enhancementCategory: An issue proposing an enhancement or a PR with one.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.F-specialization`#![feature(specialization)]`T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions