comparable icon indicating copy to clipboard operation
comparable copied to clipboard

Adds feature to allow passing attributes through to derived types (also updates dependencies and unifies workspace versioning)

Open colstrom opened this issue 1 year ago • 1 comments

Thanks for making comparable, I appreciate the work you've put into it! ❤️

This makes a handful of small(ish) changes to dependencies.

  • bumps convert_case from 0.4 -> 0.6 (version was different between comparable_derive and comparable_helper).
  • moves all shared dependencies to the workspace, so all packages depend on the same versions.
    • dependencies that were not shared remain at the package-level.
  • uses workspace-level versioning, since these crates are interdependent and released together.
  • bumps the crate version from 0.5.4 -> 0.5.5, since none of these changes should break anything (tests still pass and no functionality was altered).

These changes are each a separate commit, in case any of these things are not desirable.

If you'd like me to revise or omit any of those, just let me know!

Thanks!

colstrom avatar Sep 26 '24 23:09 colstrom

This extra change is a bit bigger than the previous one: it adds an additional attribute: comparable_attribute, which can be used to pass extra attributes through to the derived types. This is primarily intended for doing this:

#[comparable_attribute(serde(crate = "some::imported::serde"))]

for cases where serde is not a direct dependency, but provided by some other dependency via re-exporting. Without this feature, we end up with a bunch of E0658 errors.

The general functionality isn't serde-specific though. The name was chosen by looking at the current attribute names, and inferring that the comparable_* attributes seemed to refer to things about the derived types, and attempting to be consistent with that.

FWIW, It could be possible to replace the current serde integration using this feature, by doing something like:

#[comparable_attribute(derive(serde::Deserialize, serde::Serialize))]

but I didn't do that, since that would be a breaking change to the current interface for no obvious benefit.

No changes were made to the versioning, since the previous change is unmerged, and this also is a non-breaking change. Arguably it could be a minor bump, since it is new functionality. If you'd like me to bump the minor version, just let me know.

Thanks for considering this feature! ❤️

colstrom avatar Nov 04 '24 20:11 colstrom

Hi @colstrom! I'm sorry it's been a while before I saw this. If you can help to resolve the conflicts in the Cargo.toml files, I'd be happy to merge this!

jwiegley avatar Nov 15 '25 20:11 jwiegley