Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
gbersac opened this issue Sep 1, 2015 · 2 comments
Closed

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

gbersac opened this issue Sep 1, 2015 · 2 comments

Comments

@gbersac
Copy link

gbersac commented Sep 1, 2015

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.

@Gankra
Copy link
Contributor

Gankra commented Sep 1, 2015

Should be fine to display the elements -- probably an oversight?

@gbersac
Copy link
Author

gbersac commented Sep 1, 2015

Probably an oversight. Implementing the solution shouldn't take more than a line (few at most) and it is annoying that you can't easily implement debug for struct owning one BinaryHeap.

@bors bors closed this as completed in 8db906c Sep 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants