Skip to content

Debug impls of ExtractIf have inconsistent trait bounds #137654

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.T-libs-api[DEPRECATED; DO NOT USE]

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions