Downcast this error into a shared `&E` borrow. If this error is an `E`, then `Some(&E)` is returned. Otherwise, `None` is returned. If there are multiple instances of `E` in this error's chain, then the first (as encountered by [`Error::chain`]'s iteration order) is returned. # Example ``` # use wasmtime_internal_core as wasmtime; use wasmtime::error::{Error, OutOfMemory}; let error = Error::
(&self)
| 1050 | /// ); |
| 1051 | /// ``` |
| 1052 | pub fn downcast_ref<E>(&self) -> Option<&E> |
| 1053 | where |
| 1054 | E: fmt::Display + fmt::Debug + Send + Sync + 'static, |
| 1055 | { |
| 1056 | self.error_ext_chain().find_map(|e| { |
| 1057 | let result = e.inner.downcast_ref::<E>(); |
| 1058 | |
| 1059 | #[cfg(feature = "anyhow")] |
| 1060 | let result = result.or_else(|| { |
| 1061 | e.inner |
| 1062 | .downcast_ref::<anyhow::Error>() |
| 1063 | .and_then(|anyhow| anyhow.downcast_ref::<E>()) |
| 1064 | }); |
| 1065 | |
| 1066 | result |
| 1067 | }) |
| 1068 | } |
| 1069 | |
| 1070 | /// Downcast this error into an exclusive `&mut E` borrow. |
| 1071 | /// |
nothing calls this directly
no test coverage detected