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

feat: Debug for Value and Key to be optional #816

Closed
dzmitry-lahoda opened this issue Jun 27, 2024 · 5 comments
Closed

feat: Debug for Value and Key to be optional #816

dzmitry-lahoda opened this issue Jun 27, 2024 · 5 comments

Comments

@dzmitry-lahoda
Copy link

error[E0277]: `User` doesn't implement `Debug`
  --> examples/borsh.rs:12:22
   |
12 | impl redb::Value for User {
   |                      ^^^^ `User` cannot be formatted using `{:?}`
   |
   = help: the trait `Debug` is not implemented for `User`
   = note: add `#[derive(Debug)]` to `User` or manually `impl Debug for User`
note: required by a bound in `Value`
  --> /home/dz/github.com/cberner/redb/src/types.rs:74:18
   |
74 | pub trait Value: Debug {
   |                  ^^^^^ required by this bound in `Value`
help: consider annotating `User` with `#[derive(Debug)]`
   |
8  | #[derive(Debug)]
   |

error[E0277]: `Id` doesn't implement `Debug`
  --> examples/borsh.rs:50:22
   |
50 | impl redb::Value for Id {
   |                      ^^ `Id` cannot be formatted using `{:?}`
   |
   = help: the trait `Debug` is not implemented for `Id`
   = note: add `#[derive(Debug)]` to `Id` or manually `impl Debug for Id`
note: required by a bound in `Value`
  --> /home/dz/github.com/cberner/redb/src/types.rs:74:18
   |

I would like to avoid Debug in our production code, only in test, so Debug for sure does not slows performance.

Debug is optional feature.

@cberner
Copy link
Owner

cberner commented Jun 29, 2024

If you're worried about performance, you should be able to use cfg in your Debug implementation to make it a no-op in production. Is there a reason that doesn't work?

@dzmitry-lahoda
Copy link
Author

I guess yes, this is workaround. So it will not allow to read behavior out of struct definition.

@dzmitry-lahoda
Copy link
Author

dzmitry-lahoda commented Jun 29, 2024

Also, workaround does not guarant redb does not creates some temporal structures which are compiled away without being created just for Debug.

@dzmitry-lahoda
Copy link
Author

Debug is poor man json serde kind of, it should be optional feat of redb, like redb could have optional support of some serde kinds of for example.

@cberner
Copy link
Owner

cberner commented Jun 29, 2024

I decided not to add support in redb for serde. You can find the reasoning in past issues, such as this one: #805

@cberner cberner closed this as completed Jun 29, 2024
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