You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to be able to use methods from both traits, but am unable to use both since they have the same name:
use futures::TryFutureExt;
use snafu::TryFutureExt;
It's possible to work around this:
use futures::TryFutureExt;
use snafu::TryFutureExt as SnafuTryFutureExt;
But this won't be suggested by rust-analyzer, etc. Ideally, it would be possible to use both simultaneously. It might be helpful to rename the trait in snafu (possibly providing an alias for backwards compatibility). Alternatively, I could just use await.context(...) (eg., use ResultExt instead of TryFutureExt), but that raises the question of why there needs to be a TryFutureExt at all.
The text was updated successfully, but these errors were encountered:
But this won't be suggested by rust-analyzer, etc.
This sounds to me like R-A's problem, not Snafu's. Using traits (or other items) that need to be renamed1 on import is something Rust users need to be prepared to do, so, if Rust users depend on R-A to do it for them, R-A needs to be prepared to do so.
I agree that this isn't really something that libraries should work around. I recommend using the _ import, and that's what the snafu::prelude. Ideally, all of the SNAFU docs will use this form (please let me know if you find any that don't!).
Alternatively, I could just use await.context(...) (eg., use ResultExt instead of TryFutureExt), but that raises the question of why there needs to be a TryFutureExt at all.
Absolutely! SNAFU's future combinators were added a long while ago — I think before async and await were added to the language. When writing async code, you need to be careful of when you place your .awaits so that you don't lose concurrency. For example:
let a = a.await.context(...);let b = b.await.context(...);// b will happen *after* a// vslet a = a.context(...);let b = b.context(...);let(a, b) = join!(a, b);// a and b will happen concurrently // or without SNAFU's combinatorslet a = async{ a.await.context(...)};let b = async{ b.await.context(...)};let(a, b) = join!(a, b);// a and b will happen concurrently
I'd like to be able to use methods from both traits, but am unable to use both since they have the same name:
It's possible to work around this:
But this won't be suggested by rust-analyzer, etc. Ideally, it would be possible to use both simultaneously. It might be helpful to rename the trait in
snafu
(possibly providing an alias for backwards compatibility). Alternatively, I could just useawait.context(...)
(eg., use ResultExt instead of TryFutureExt), but that raises the question of why there needs to be aTryFutureExt
at all.The text was updated successfully, but these errors were encountered: