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

Implement #[key = ...] #2698

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

Implement #[key = ...] #2698

wants to merge 1 commit into from

Conversation

jun-sheaf
Copy link

@jun-sheaf jun-sheaf commented Feb 13, 2024

This PR implements the ability to use a limited set of literals for keys when serializing and deserializing structs. The motivation is written in #2695.

Closes #2695

Limitations

  • We purposefully error for string keys since this is already supported using rename.
  • Floats are not supported (Rust doesn't support them for match statements and in practice, this is not done).
  • Negative keys are not supported for the time being.
  • Keys can clash if the user wants to. (Footgun?)

{
let _ = key;
let _ = value;
Ok(())
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the default implementation error instead of silently doing nothing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Allow generic keys for serialization and deserialization
2 participants