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

Support for custom default fuction with owned pattern #315

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

Wasabi375
Copy link

@Wasabi375 Wasabi375 commented Mar 24, 2024

This is a fix for #298

I finally got back to my hobby project where I need this so I got around to implement this feature/bug fix.

I've implemented the solution I described in that issue so I won't repeat it here again. If there are any open questions I'm happy to answer them or adjust this PR.

You wouldn’t need that unwrap if you use unwrap_or, right?

No unwrap_or does not work because it expects a T and the default we have is an Option. Either we use or and than unwrap or we can use unwrap_or(default.unwrap()). I personally think that or.unwrap is a bit nicer.

PS: I know that the rust 1.59 tests are failing right now. "Syn" just published a new version "2.0.55" that requires rust 1.60.
However on my fork the 1.59 tests succeeded with the old syn version.

PPS: I know that are a lot of commits. The best solution is to just squash them I think but I am open to rebasing them into a few usefull commits if you prefer that. This is a rather large change after all.

There are still a lot of tests failing, but my usecase works.
Now I just have to fix all the corner cases. Also tests for the new
feature are still missing.
this still leaves tests in all other packages including tests for
internals in derive_builder_core
turns out having a todo in the test data generation is not good if you
want the tests to pass :)
conversion is only used to disable the default value if the enum is not
OptionOrDefault. It's cleaner to just use an enabled flag for that.
@Wasabi375 Wasabi375 marked this pull request as draft March 24, 2024 14:50
@Wasabi375
Copy link
Author

Woops. Turns out my simplified testcase isn't actually good enough, so I will have to do some more work on this. I'll leave this as a draft PR for now.

@Wasabi375 Wasabi375 marked this pull request as ready for review April 19, 2024 15:29
@Wasabi375
Copy link
Author

Ok, I spent the last month making sure that I did not miss anything and properly testing, this. So it should be good to merge.
Again let me know if there are any changes you'd like me to make or if I should rebase the git history to clean it up (otherwise squashing this should be fine I think).

@TedDriggs
Copy link
Collaborator

I'm not sure when I'll have time to review this, but I have it on my to-do list.

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