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

utility additions to ImmediateValuePromise #13

Merged
merged 2 commits into from
Oct 17, 2024
Merged

Conversation

tomellm
Copy link
Contributor

@tomellm tomellm commented Oct 16, 2024

After using lazy_async_promise with a lot of success for a while I noticed that these two things would be useful additions to the toolset.

1. get_result and take_result

I often find myself working with promises where I wait for them to stop updating after which I wan't to get the success or the error value which is where these functions have come very much in handy.

2. impl From<T: std::future::Future + Send + 'static>

This might be personal preference but I dislike the constant wrapping of futures to create ImmediateValuePromise's so I implemented the the From trait for T: std::future::Future + Send + 'static for very easy conversion with .into().


I don't know if this proposal is a bit unsolicited but I much enjoy using this crate and would love to make it even more useful in my eyes. If there are tests I should add or changes I should make feel free to tell me so.

They get and take a "Option<Result<_, _>>" object out of the DirectCacheAccess implementor.
When None the status was updating or blank and if the result is present the status was success
or error.
makes it easier to work with ImmediateValuePromise's since all that is
needed to create one is a ".into()".
@ChrisRega
Copy link
Owner

Thanks for the PR, will review this evening :)

@ChrisRega
Copy link
Owner

This looks super convenient. Could you please fix the pipeline-errors and add an example for the new methods? A doctest could just work fine here.

@ChrisRega ChrisRega merged commit 8faecee into ChrisRega:main Oct 17, 2024
0 of 3 checks passed
@tomellm
Copy link
Contributor Author

tomellm commented Oct 17, 2024

Sorry I didn't get to it, should I open a new PR with the doc additions?

@ChrisRega
Copy link
Owner

@tomellm nevermind, had some time and fixed everything after merge. New version is already released as 0.6.0. Thank you for your contribution.

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.

2 participants