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(DeriveAttribute) Implement derive macro attribute for format #131

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

johnhurt
Copy link

Build on the newly-introduced derive-attribute framework to allow fields in structs to be written to the final value as a formatted string instead of their actual value. This allows for types that don't (and can't or won't) implement Valuable to be included in the value

@taiki-e
Copy link
Member

taiki-e commented Sep 6, 2024

Thanks for the PR!

@johnhurt
Copy link
Author

johnhurt commented Sep 10, 2024

Ooooooh, I see what you mean. Let me tackle those one at a time

  1. That doesn't seem like a good thing. I didn't think about the ability to leak things out with a format. I will change this from #[valuable(format = "{}")] to just #[valuable(debug)] to avoid
  2. There doesn't seem to be a way around allocating to do what I'm trying to do. Even to complete Consider other Value primitive variants #4 I think would require allocation :-/ ... Would you be open to the idea of adding an opt-in alloc feature that would gate the #[valuable(debug)] attribute?

@taiki-e
Copy link
Member

taiki-e commented Sep 15, 2024

Adding Debug/Display (or Debugable/Displayable mentioned in #43 (comment)) variant to valuable::Value and then adding #[valuable(debug)]/#[valuable(display)] that pass the field as Value::Debug/Value::Display to derive seem to good idea to me.

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

Successfully merging this pull request may close these issues.

2 participants