carllerche / syncbox

Concurrency utilities for Rust
131 stars 14 forks source link

Implement debug for atomics #39

Open obourgain opened 8 years ago

obourgain commented 8 years ago

Deriving debug would be nice to allow users to also derive debug in their own structs. Otherwise the compiler fails with something like

src/lib.rs:54:5: 54:25 error: the trait `core::fmt::Debug` is not implemented for the type `syncbox::atomic::types::AtomicU64` [E0277]
src/lib.rs:54     max_value: AtomicU64
                  ^~~~~~~~~~~~~~~~~~~~
src/lib.rs:41:10: 41:15 note: in this expansion of #[derive_Debug] (defined in src/lib.rs)
src/lib.rs:54:5: 54:25 help: run `rustc --explain E0277` to see a detailed explanation
src/lib.rs:54:5: 54:25 note: `syncbox::atomic::types::AtomicU64` cannot be formatted using `:?`; if it is defined in your crate, add `#[derive(Debug)]` or manually implement it
src/lib.rs:54:5: 54:25 note: required for the cast to the object type `core::fmt::Debug`
obourgain commented 8 years ago

I would also like to have #[derive(Default)]

obourgain commented 8 years ago

My current workaround is to define a simple wrapper struct around AtomicU64 and implement Debug and Default myself