Skip to content

Debug impls of ExtractIf have inconsistent trait bounds #137654

@dtolnay

Description

@dtolnay

std::vec::ExtractIf has:

impl<T, F> Debug for ExtractIf<'_, T, F>
where
    T: Debug,
    F: Debug;

std::collections::linked_list::ExtractIf has:

impl<T, F> Debug for ExtractIf<'_, T, F>
where
    T: Debug;

std::collections::hash_set::ExtractIf has:

impl<T, F> Debug for ExtractIf<'_, T, F>
where
    F: FnMut(&T) -> bool;

std::collections::btree_set::ExtractIf has:

impl<T, F> Debug for ExtractIf<'_, T, F>
where
    T: Debug,
    F: FnMut(&T) -> bool;
Vec LinkedList HashSet BTreeSet
T: Debug ☑️ ☑️ ☑️
F: Debug ☑️
F: FnMut ☑️ ☑️

There should not need to be 4 different permutations for these 4 effectively-identical interfaces. We should be able to decide:

  • Should collection elements be printed or not.
  • Should the predicate be printed or not. Almost certainly not, given that closures do not implement Debug.
  • Should the Debug impl ever need to invoke the predicate. Almost certainly not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions