Skip to content
Myr

Add AsRef impls for Error

Before adoption: this commit came in with the history the project adopted, so no landing records it.

These are potentially friendlier than fiddling with &** to get the trait object. let _: &dyn StdError = error.as_ref();

authored by David Tolnay · committed by David Tolnay · parent 645a81c · Browse files · 1 file+12 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+12 added−0 removed

  • other:+12 added−0 removed

1 file+12 added−0 removed

modified:src/error.rs+12 added
781 unmodified lines
782 fn from(error: Error) -> Self {783 Box::<dyn StdError + Send + Sync>::from(error)784 }785}786787impl AsRef<dyn StdError + Send + Sync> for Error {788 fn as_ref(&self) -> &(dyn StdError + Send + Sync + 'static) {789 &**self790 }791}792793impl AsRef<dyn StdError> for Error {794 fn as_ref(&self) -> &(dyn StdError + 'static) {795 &**self796 }797}