Custom Constructors for Components causing an error with Futures
I have a custom constructor with a very basic example, but it consistently results in the following error:
#[derive(Component)]
| ^^^^^^^^^
| |
| Result<HandlebarsEngineImpl, Arc<dyn StdError + Send + Sync>> is not a future
| this call returns Result<HandlebarsEngineImpl, Arc<dyn StdError + Send + Sync>>
|
= help: the trait Future is not implemented for Result<HandlebarsEngineImpl, Arc<dyn StdError + Send + Sync>>, which is required by Result<HandlebarsEngineImpl, Arc<dyn StdError + Send + Sync>>: IntoFuture
= note: Result<HandlebarsEngineImpl, Arc<dyn StdError + Send + Sync>> must be a future or must implement IntoFuture to be awaited
= note: required for Result<HandlebarsEngineImpl, Arc<dyn StdError + Send + Sync>> to implement IntoFuture
You seem to be using the async feature while your constructor doesn't return a future. Either turn off async or return a future, even trivial one.
Thank you! It looks like that was exactly the issue. I ultimately changed my implementation, but I might open a PR with this as an example, if thats okay?
PRs are always welcome. Will this example by different than https://github.com/krojew/springtime/blob/master/springtime-di/examples/06-custom-constructor.rs?
It would be almost identical, aside from the fact that the constructor would return a future.
Out of curiosity, without hi-jacking this thread, is there a big benefit to using the Async flag?
Not everything can be constructed synchronously, so async is required in such cases.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.