Skip to content

Question - any particular reason why Debug trait isn't derived for the Value enum? #2931

Closed Answered by hudson-ayers
nihalpasham asked this question in Q&A
Discussion options

You must be logged in to vote

The main reason to avoid using #[derive(Debug)] is that Rust's formatting machinery is pretty heavy and relying on it to print much leads to binaries with a lot of bloat as a result (see https://github.com/tock/tock/blob/master/doc/CodeSize.md#formatting-overhead and https://jamesmunns.com/blog/fmt-unreasonably-expensive/ for discussions of this). Of course, by simply not printing the value in question you avoid the code size overhead, so we could derive Debug without hurting code size in the common case -- it just lowers the barrier to more widespread use of Debug which can ultimately lead to code bloat.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by nihalpasham
Comment options

You must be logged in to vote
1 reply
@hudson-ayers
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants