rust-lang / prev.rust-lang.org

The previous Rust website. The current website's code is at https://github.com/rust-lang/www.rust-lang.org.
https://prev.rust-lang.org
Apache License 2.0
151 stars 340 forks source link

FAQ: Add "Why does Rust not #[derive(Debug)] by default?" #1073

Closed kud1ing closed 4 years ago

kud1ing commented 6 years ago

Asked on Reddit at least two times:

@llogiq's answer is a good start; https://www.reddit.com/r/rust/comments/8677z1/why_does_rust_not_derivedebug_by_default/dw378lk/

Not sure where this should go to. Maybe under the "Debugging and Tooling" section.

llogiq commented 6 years ago

We should perhaps stress the third point more – that the cost of requiring #[derive(Debug)] is acceptable in exchange for a safe default (not having it in the first place).

Incidentally, this argument also applies to auto-deriving Default. The code bloat argument is weaker there, because the method is smaller, can likely be constified and inlined.