Skip to content

Update ToCoroutineEnumerator<T> to return a T? from Current instead of object #660

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

TheCrossBoy
Copy link

@TheCrossBoy TheCrossBoy commented Apr 17, 2025

ToCoroutine<T>() provides an excellent way to port existing synchronous calls to asynchronous without needing to fully rewrite everything - when inside a coroutine, it can be yielded instead.

To get the value that the previously-synchronous function would have returned, you use .Current. Right now, Current is an object, when it should be a T. I think this might have been to avoid problems with non-nullable / reference types, so I wrapped it in Nullable (with T?).

Eliminates extra unnecessary typecasting with this.

@TheCrossBoy TheCrossBoy changed the title Update ToCoroutineEnumerator<T> to return a T from Current instead of object Update ToCoroutineEnumerator<T> to return a T? from Current instead of object Apr 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant