Dummy task
MiniaczQ opened this issue · 2 comments
MiniaczQ commented
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 commented
Is there any reason why you can't use async { my_value }
as your future in this case?
notgull commented
Closing this issue. I think that the above solution should work in all cases. Let me know if you have any other questions.