Skip to content

Dummy task #35

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

Closed
MiniaczQ opened this issue Oct 10, 2022 · 2 comments
Closed

Dummy task #35

MiniaczQ opened this issue Oct 10, 2022 · 2 comments

Comments

@MiniaczQ
Copy link

MiniaczQ commented Oct 10, 2022

Ability to create an already completed Task with something like Task::completed(...).

This would serve as a way to mock asynchronous functionality with synchronous code.

My specific use case is an interface which has to return a Task, but the actual code doesn't have a way to create said Task.
(I don't think this solution can be called sound, but it is what it is)
source

This is very much inspired by C#.

@notgull
Copy link
Member

notgull commented Nov 9, 2022

Is there any reason why you can't use async { my_value } as your future in this case?

@notgull
Copy link
Member

notgull commented Mar 23, 2023

Closing this issue. I think that the above solution should work in all cases. Let me know if you have any other questions.

@notgull notgull closed this as completed Mar 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants