rust-derive-builder icon indicating copy to clipboard operation
rust-derive-builder copied to clipboard

Support for custom default fuction with owned pattern

Open Wasabi375 opened this issue 1 year ago • 3 comments

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.

Wasabi375 avatar Mar 24 '24 03:03 Wasabi375

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 avatar Mar 24 '24 14:03 Wasabi375

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).

Wasabi375 avatar Apr 19 '24 15:04 Wasabi375

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

TedDriggs avatar Apr 23 '24 19:04 TedDriggs