Skip to content

Implement the trait debug for std::collections::BinaryHeap #28154

Closed
@gbersac

Description

@gbersac

If I run the following code :

use std::collections::BinaryHeap;

#[derive(Debug)]
pub struct MyStruct
{
    bh: BinaryHeap<i32>,
}

fn main() {
    let m = MyStruct {
        bh: BinaryHeap::new(),
    };
}

I get the following error :

test.rs:6:2: 6:21 error: the trait `core::fmt::Debug` is not implemented for the type `collections::binary_heap::BinaryHeap<i32>` [E0277]
test.rs:6   bh: BinaryHeap<i32>,
            ^~~~~~~~~~~~~~~~~~~~~~~
test.rs:3:10: 3:15 note: in expansion of #[derive_Debug]
test.rs:3:10: 3:15 note: expansion site
test.rs:6:2: 6:21 note: `collections::binary_heap::BinaryHeap<i32>` cannot be formatted using `:?`; if it is defined in your crate, add `#[derive(Debug)]` or manually implement it
test.rs:6   bh: BinaryHeap<i32>,
            ^~~~~~~~~~~~~~~~~~~~~~~
test.rs:3:10: 3:15 note: in expansion of #[derive_Debug]
test.rs:3:10: 3:15 note: expansion site
error: aborting due to previous error

I don't see any reason for the trait Debug not to be implemented for BinaryHeap. If seeing the nodes of it is a problem, at least a ByanryHeap[size: x] could be enough.

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