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

in to_extend take collection by mutable reference #208

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

Conversation

e00E
Copy link

@e00E e00E commented Feb 1, 2025

Currently the function takes the collection by value. Taking by mutable reference is better because it is more flexible. Whenever you have a value, you can also pass by mutable reference, but sometimes you only have a mutable reference and cannot pass by value.

This also fixes another problem with the current API: It keeps the collection on error. On success it returns it to the caller, but on error it does not. This makes the caller lose the collection.

Currently the function takes the collection by value. Taking by mutable reference is better because it is more flexible. Whenever you have a value, you can also pass by mutable reference, but sometimes you only have a mutable reference and cannot pass by value.

This also fixes another problem with the current API: It keeps the collection on error. On success it returns it to the caller, but on error it does not. This makes the caller lose the collection.
Copy link

netlify bot commented Feb 1, 2025

Deploy Preview for cute-starship-2d9c9b canceled.

Name Link
🔨 Latest commit e402519
🔍 Latest deploy log https://app.netlify.com/sites/cute-starship-2d9c9b/deploys/679e04d4fbfa230008991ffa

@jamesmunns
Copy link
Owner

This would be a breaking API change, so it is unlikely to be merged before postcard 2.0.

It seems reasonable to me to merge in the future though.

@jamesmunns jamesmunns added the postcard-2.0 Tracking issues for an eventual 2.0 version of the postcard wire format (not currently planned) label Feb 1, 2025
@e00E
Copy link
Author

e00E commented Feb 1, 2025

Yes, it is a breaking change. For a non breaking version we could add a to_extend_mut function. Would you like that?

@jamesmunns
Copy link
Owner

I'm open to looking at non-breaking changes, if there's a way you think it could be done, or as a separate ExtendMut flavor or something. In general, we can always add new trait impls (or make additions to existing ones), just changing existing ones is harder to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
postcard-2.0 Tracking issues for an eventual 2.0 version of the postcard wire format (not currently planned)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants