Conversation
| * @template U | ||
| * | ||
| * @param U $optb | ||
| * @return T|U | ||
| */ | ||
| abstract public function unwrapOr($optb); | ||
|
|
||
| /** | ||
| * Returns the contained value or computes it from a callable. | ||
| * | ||
| * @param callable(): T $op | ||
| * @return T | ||
| * @template U | ||
| * | ||
| * @param callable(): U $op | ||
| * @return T|U |
There was a problem hiding this comment.
This change will make it behave differently from the Rust implementation. It looks like the these methods there return the same type of value as contained in the Option itself. Here are the docs for reference. So I think this should be as it was before.
There was a problem hiding this comment.
Imho it doesn't have to slavishly like Rust, this makes it more flexible. Rust has much better language level constructs to handle Options/Results, so a bit of leeway is, I think, acceptable.
There was a problem hiding this comment.
I agree with this reasoning FWIW, the goal of the lib is to deliver value to the PHP language.
|
Unfortunately some of the CI is a bit dusty. Let's ignore that failed job. |
|
Please do the result one as well, and I'll make a release afterwards. |
Here it is prewk/result#43 |
As discussed in #42
If this is fine I can submit an analogous PR for prewk/result.