Skip to content

feat(DeriveAttribute) Implement derive macro attribute for format - #131

Closed
johnhurt wants to merge 1 commit into
tokio-rs:masterfrom
johnhurt:format-derive-attr
Closed

feat(DeriveAttribute) Implement derive macro attribute for format#131
johnhurt wants to merge 1 commit into
tokio-rs:masterfrom
johnhurt:format-derive-attr

Conversation

@johnhurt

Copy link
Copy Markdown

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

taiki-e commented Sep 6, 2024

Copy link
Copy Markdown
Member

Thanks for the PR!

@johnhurt

johnhurt commented Sep 10, 2024

Copy link
Copy Markdown
Author

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

taiki-e commented Sep 15, 2024

Copy link
Copy Markdown
Member

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.

@johnhurt

Copy link
Copy Markdown
Author

I'm closing this in favor of #133

@johnhurt johnhurt closed this Jan 26, 2025
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