samber / mo

🦄 Monads and popular FP abstractions, powered by Go 1.18+ Generics (Option, Result, Either...)
https://pkg.go.dev/github.com/samber/mo
MIT License
2.47k stars 80 forks source link

Option: Add PointerOrNil #25

Closed m110 closed 10 months ago

m110 commented 1 year ago

Hey, thanks for the project!

One thing I missed when working with Option is to convert it to a pointer easily. It's like the opposite of PointerToOption.

It would be useful when converting values for structs used for marshaling. In my case, it's OpenAPI-generated structs with fields like *string, etc.

If you like the idea, I'll add examples and docs.

ilya-hontarau commented 10 months ago

@samber any updates about this?

samber commented 10 months ago

Sorry for the late review.

Let's merge ;)

I will update the doc and playground demo.