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

andThen() #379

Open
1 of 3 tasks
veewee opened this issue Dec 16, 2022 · 1 comment · Fixed by #398
Open
1 of 3 tasks

andThen() #379

veewee opened this issue Dec 16, 2022 · 1 comment · Fixed by #398
Assignees
Labels
Type: Enhancement Most issues will probably ask for additions or changes.

Comments

@veewee
Copy link
Collaborator

veewee commented Dec 16, 2022

Introduce new andThen method: https://doc.rust-lang.org/rust-by-example/error/option_unwrap/and_then.html
This method can be used to e.g. map an Option into another option:

some(1)->andThen(fn(int $value) => $value > 1 ? some($value) : none())  == none();

They apply to:

  • Result
  • Option
  • maybe: Promise?

❗ Currently Result::then() allows returning a promise which automatically gets unwrapped. That logic should be deprecated and removed in v3 since it's rather magically. The new andThen function should be used for this purpose. We'll have to add a note for that in the code and release notes.

(to investigate: if it makes sense to keep on supporting it during runtime, but make psalm fail)

@veewee veewee added the Type: Enhancement Most issues will probably ask for additions or changes. label Dec 16, 2022
@azjezz azjezz added this to the 3.0.0 milestone Dec 19, 2022
@veewee veewee reopened this Jan 24, 2023
@azjezz
Copy link
Owner

azjezz commented Jan 24, 2023

(to investigate: if it makes sense to keep on supporting it during runtime, but make psalm fail)

I think that's the right way of deprecating it, as it won't break peoples code, only SA builds.

@veewee veewee removed this from the 2.4.0 milestone May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Most issues will probably ask for additions or changes.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants