Hey @rustlang twitter: any particular reason that there isn't an instance of std::error::Error for Arc<dyn std::error::Error>?
Would be quite useful when you want a cloneable dyn error for just exploring things without being bogged down in error handling intricacies...
-
-
Arc<dyn Error> and Box<dyn Error> cannot impl Error due to the overlap rule which says currently in rust you cannot have two generic trait impls both be valid for the same type. From<T> for Arc<T> and From<T> for T would overlap if Arc<dyn Error> itself could coerce to dyn Error
2 replies 0 retweets 5 likes -
This would be true if there was `impl<E: Error> From<E> for Arc<dyn Error>`, but there is no such impl. Only for Box.
1 reply 0 retweets 1 like -
Oh yea you need a concrete impl don't you, I forgot the From<T> doesn't work as a coersion site for dyn Error.
1 reply 0 retweets 0 likes -
Either way, you can't meaningfully get what
@klaehnr wants which is presumably a catch all error type via Arc that itself impls Error. Side question, Sian do you know if specialization is planned to allow overlap?2 replies 0 retweets 0 likes -
You definitely could write `impl<E: Error + ?Sized> Error for Arc<E>`.There's nothing incoherent about it.
1 reply 0 retweets 1 like -
Yaah 🦀 Retweeted Yaah 🦀
Yaah 🦀 added,
1 reply 0 retweets 0 likes -
The `Sized` bound doesn't need to be there
1 reply 0 retweets 1 like -
Or rather could be `?Sized`
2 replies 0 retweets 0 likes -
But then you wouldn't be able to use ? With an Arc<dyn Error> right?
1 reply 0 retweets 0 likes
You'd need a `From` impl if you wanted to be able to put `?` on any error on a function returning `Arc<dyn Error>`, yes. That wasn't really the question that was asked though.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.