diff --git a/crates/gpui/src/asset_cache.rs b/crates/gpui/src/asset_cache.rs index 3c6dbd99da..9afbba8a0e 100644 --- a/crates/gpui/src/asset_cache.rs +++ b/crates/gpui/src/asset_cache.rs @@ -1,5 +1,5 @@ use crate::{App, SharedString, SharedUri}; -use futures::Future; +use futures::{Future, TryFutureExt}; use std::fmt::Debug; use std::hash::{Hash, Hasher}; @@ -51,14 +51,17 @@ pub trait Asset: 'static { ) -> impl Future + Send + 'static; } -/// An asset Loader that logs whatever passes through it +/// An asset Loader which logs the [`Err`] variant of a [`Result`] during loading pub enum AssetLogger { #[doc(hidden)] _Phantom(PhantomData, &'static dyn crate::seal::Sealed), } -impl>> Asset - for AssetLogger +impl Asset for AssetLogger +where + T: Asset>, + R: Clone + Send, + E: Clone + Send + std::fmt::Display, { type Source = T::Source; @@ -69,10 +72,7 @@ impl impl Future + Send + 'static { let load = T::load(source, cx); - async { - load.await - .inspect_err(|e| log::error!("Failed to load asset: {}", e)) - } + load.inspect_err(|e| log::error!("Failed to load asset: {}", e)) } }