Skip to content

Conversation

@lukas-reineke
Copy link

Introduces a new #[valuable(with = "function")] attribute that allows custom field transformations during valuable serialization. Similar to serdes #[serde(serialize_with = "function")].
Functions take a reference to the field and return any type implementing Valuable.

Example

  fn debug_format<T: std::fmt::Debug>(value: &T) -> String {
      format!("{value:?}")
  }

  #[derive(Valuable)]
  struct Foo {
      #[valuable(with = "debug_format")]
      bar: HashMap<String, bool>,
  }

As far as I can tell, this works, but this is the first time I'm writing a proc macro, it's very likely that I'm missing something.

Introduces a new `#[valuable(with = "function")]` attribute that allows
custom field transformations during valuable serialization. Functions
take a reference to the field and return any type implementing Valuable.
@lukas-reineke lukas-reineke force-pushed the with-attr-for-derive-macro branch from 7663826 to 9d430bd Compare August 8, 2025 11:22
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.

1 participant