From 73af2b7d291b108d220941e9ce41a3130babbd97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristoffer=20S=C3=B8holm?= Date: Mon, 30 Sep 2024 23:54:59 +0200 Subject: [PATCH] Cleanup unneeded lifetimes in bevy_asset (#15546) # Objective Fixes #15541 A bunch of lifetimes were added during the Assets V2 rework, but after moving to async traits in #12550 they can be elided. That PR mentions that this might be the case, but apparently it wasn't followed up on at the time. ~~I ended up grepping for `<'a` and finding a similar case in `bevy_reflect` which I also fixed.~~ (edit: that one was needed apparently) Note that elided lifetimes are unstable in `impl Trait`. If that gets stabilized then we can elide even more. ## Solution Remove the extra lifetimes. ## Testing Everything still compiles. If I have messed something up there is a small risk that some user code stops compiling, but all the examples still work at least. --- ## Migration Guide The traits `AssetLoader`, `AssetSaver` and `Process` traits from `bevy_asset` now use elided lifetimes. If you implement these then remove the named lifetime. --- crates/bevy_animation/src/graph.rs | 10 +++---- crates/bevy_asset/src/lib.rs | 10 +++---- crates/bevy_asset/src/loader.rs | 10 +++---- crates/bevy_asset/src/meta.rs | 18 +++++------ crates/bevy_asset/src/processor/mod.rs | 26 ++++++++-------- crates/bevy_asset/src/processor/process.rs | 16 +++++----- crates/bevy_asset/src/saver.rs | 14 ++++----- crates/bevy_asset/src/server/info.rs | 6 ++-- crates/bevy_asset/src/server/loaders.rs | 20 ++++++------- crates/bevy_asset/src/server/mod.rs | 16 +++++----- crates/bevy_audio/src/audio_source.rs | 12 ++++---- crates/bevy_gltf/src/loader.rs | 10 +++---- crates/bevy_pbr/src/meshlet/asset.rs | 20 ++++++------- .../bevy_render/src/render_resource/shader.rs | 10 +++---- .../src/texture/compressed_image_saver.rs | 10 +++---- .../src/texture/exr_texture_loader.rs | 10 +++---- .../src/texture/hdr_texture_loader.rs | 10 +++---- .../bevy_render/src/texture/image_loader.rs | 10 +++---- crates/bevy_scene/src/scene_loader.rs | 10 +++---- crates/bevy_text/src/font_loader.rs | 10 +++---- examples/asset/asset_decompression.rs | 11 +++---- examples/asset/custom_asset.rs | 20 ++++++------- examples/asset/processing/asset_processing.rs | 30 +++++++++---------- 23 files changed, 160 insertions(+), 159 deletions(-) diff --git a/crates/bevy_animation/src/graph.rs b/crates/bevy_animation/src/graph.rs index 1ce683409a..5264cf9a23 100644 --- a/crates/bevy_animation/src/graph.rs +++ b/crates/bevy_animation/src/graph.rs @@ -508,11 +508,11 @@ impl AssetLoader for AnimationGraphAssetLoader { type Error = AnimationGraphLoadError; - async fn load<'a>( - &'a self, - reader: &'a mut dyn Reader, - _: &'a Self::Settings, - load_context: &'a mut LoadContext<'_>, + async fn load( + &self, + reader: &mut dyn Reader, + _: &Self::Settings, + load_context: &mut LoadContext<'_>, ) -> Result { let mut bytes = Vec::new(); reader.read_to_end(&mut bytes).await?; diff --git a/crates/bevy_asset/src/lib.rs b/crates/bevy_asset/src/lib.rs index df5879609d..af957b4545 100644 --- a/crates/bevy_asset/src/lib.rs +++ b/crates/bevy_asset/src/lib.rs @@ -676,11 +676,11 @@ mod tests { type Error = CoolTextLoaderError; - async fn load<'a>( - &'a self, - reader: &'a mut dyn Reader, - _settings: &'a Self::Settings, - load_context: &'a mut LoadContext<'_>, + async fn load( + &self, + reader: &mut dyn Reader, + _settings: &Self::Settings, + load_context: &mut LoadContext<'_>, ) -> Result { let mut bytes = Vec::new(); reader.read_to_end(&mut bytes).await?; diff --git a/crates/bevy_asset/src/loader.rs b/crates/bevy_asset/src/loader.rs index 2160b5bf99..aa66985631 100644 --- a/crates/bevy_asset/src/loader.rs +++ b/crates/bevy_asset/src/loader.rs @@ -30,11 +30,11 @@ pub trait AssetLoader: Send + Sync + 'static { /// The type of [error](`std::error::Error`) which could be encountered by this loader. type Error: Into>; /// Asynchronously loads [`AssetLoader::Asset`] (and any other labeled assets) from the bytes provided by [`Reader`]. - fn load<'a>( - &'a self, - reader: &'a mut dyn Reader, - settings: &'a Self::Settings, - load_context: &'a mut LoadContext, + fn load( + &self, + reader: &mut dyn Reader, + settings: &Self::Settings, + load_context: &mut LoadContext, ) -> impl ConditionalSendFuture>; /// Returns a list of extensions supported by this [`AssetLoader`], without the preceding dot. diff --git a/crates/bevy_asset/src/meta.rs b/crates/bevy_asset/src/meta.rs index 53c1db824d..bad3a4be72 100644 --- a/crates/bevy_asset/src/meta.rs +++ b/crates/bevy_asset/src/meta.rs @@ -173,11 +173,11 @@ impl Process for () { type Settings = (); type OutputLoader = (); - async fn process<'a>( - &'a self, - _context: &'a mut bevy_asset::processor::ProcessContext<'_>, + async fn process( + &self, + _context: &mut bevy_asset::processor::ProcessContext<'_>, _meta: AssetMeta<(), Self>, - _writer: &'a mut bevy_asset::io::Writer, + _writer: &mut bevy_asset::io::Writer, ) -> Result<(), bevy_asset::processor::ProcessError> { unreachable!() } @@ -196,11 +196,11 @@ impl AssetLoader for () { type Asset = (); type Settings = (); type Error = std::io::Error; - async fn load<'a>( - &'a self, - _reader: &'a mut dyn crate::io::Reader, - _settings: &'a Self::Settings, - _load_context: &'a mut crate::LoadContext<'_>, + async fn load( + &self, + _reader: &mut dyn crate::io::Reader, + _settings: &Self::Settings, + _load_context: &mut crate::LoadContext<'_>, ) -> Result { unreachable!(); } diff --git a/crates/bevy_asset/src/processor/mod.rs b/crates/bevy_asset/src/processor/mod.rs index f9fd23f0b7..0030b890d8 100644 --- a/crates/bevy_asset/src/processor/mod.rs +++ b/crates/bevy_asset/src/processor/mod.rs @@ -83,7 +83,7 @@ use thiserror::Error; /// [`AssetProcessor`] can be run in the background while a Bevy App is running. Changes to assets will be automatically detected and hot-reloaded. /// /// Assets will only be re-processed if they have been changed. A hash of each asset source is stored in the metadata of the processed version of the -/// asset, which is used to determine if the asset source has actually changed. +/// asset, which is used to determine if the asset source has actually changed. /// /// A [`ProcessorTransactionLog`] is produced, which uses "write-ahead logging" to make the [`AssetProcessor`] crash and failure resistant. If a failed/unfinished /// transaction from a previous run is detected, the affected asset(s) will be re-processed. @@ -155,10 +155,10 @@ impl AssetProcessor { /// Retrieves the [`AssetSource`] for this processor #[inline] - pub fn get_source<'a, 'b>( - &'a self, - id: impl Into>, - ) -> Result<&'a AssetSource, MissingAssetSourceError> { + pub fn get_source<'a>( + &self, + id: impl Into>, + ) -> Result<&AssetSource, MissingAssetSourceError> { self.data.sources.get(id.into()) } @@ -565,11 +565,11 @@ impl AssetProcessor { /// Retrieves asset paths recursively. If `clean_empty_folders_writer` is Some, it will be used to clean up empty /// folders when they are discovered. - async fn get_asset_paths<'a>( - reader: &'a dyn ErasedAssetReader, - clean_empty_folders_writer: Option<&'a dyn ErasedAssetWriter>, + async fn get_asset_paths( + reader: &dyn ErasedAssetReader, + clean_empty_folders_writer: Option<&dyn ErasedAssetWriter>, path: PathBuf, - paths: &'a mut Vec, + paths: &mut Vec, ) -> Result { if reader.is_directory(&path).await? { let mut path_stream = reader.read_directory(&path).await?; @@ -1093,11 +1093,11 @@ impl Process for InstrumentedAssetProcessor { type Settings = T::Settings; type OutputLoader = T::OutputLoader; - fn process<'a>( - &'a self, - context: &'a mut ProcessContext, + fn process( + &self, + context: &mut ProcessContext, meta: AssetMeta<(), Self>, - writer: &'a mut crate::io::Writer, + writer: &mut crate::io::Writer, ) -> impl ConditionalSendFuture< Output = Result<::Settings, ProcessError>, > { diff --git a/crates/bevy_asset/src/processor/process.rs b/crates/bevy_asset/src/processor/process.rs index 108b7ffc8d..785b23f99c 100644 --- a/crates/bevy_asset/src/processor/process.rs +++ b/crates/bevy_asset/src/processor/process.rs @@ -27,11 +27,11 @@ pub trait Process: Send + Sync + Sized + 'static { type OutputLoader: AssetLoader; /// Processes the asset stored on `context` in some way using the settings stored on `meta`. The results are written to `writer`. The /// final written processed asset is loadable using [`Process::OutputLoader`]. This load will use the returned [`AssetLoader::Settings`]. - fn process<'a>( - &'a self, - context: &'a mut ProcessContext, + fn process( + &self, + context: &mut ProcessContext, meta: AssetMeta<(), Self>, - writer: &'a mut Writer, + writer: &mut Writer, ) -> impl ConditionalSendFuture< Output = Result<::Settings, ProcessError>, >; @@ -179,11 +179,11 @@ where LoadTransformAndSaveSettings; type OutputLoader = Saver::OutputLoader; - async fn process<'a>( - &'a self, - context: &'a mut ProcessContext<'_>, + async fn process( + &self, + context: &mut ProcessContext<'_>, meta: AssetMeta<(), Self>, - writer: &'a mut Writer, + writer: &mut Writer, ) -> Result<::Settings, ProcessError> { let AssetAction::Process { settings, .. } = meta.asset else { return Err(ProcessError::WrongMetaType); diff --git a/crates/bevy_asset/src/saver.rs b/crates/bevy_asset/src/saver.rs index 19955cd62f..f2cb5bb933 100644 --- a/crates/bevy_asset/src/saver.rs +++ b/crates/bevy_asset/src/saver.rs @@ -24,12 +24,12 @@ pub trait AssetSaver: Send + Sync + 'static { type Error: Into>; /// Saves the given runtime [`Asset`] by writing it to a byte format using `writer`. The passed in `settings` can influence how the - /// `asset` is saved. - fn save<'a>( - &'a self, - writer: &'a mut Writer, - asset: SavedAsset<'a, Self::Asset>, - settings: &'a Self::Settings, + /// `asset` is saved. + fn save( + &self, + writer: &mut Writer, + asset: SavedAsset<'_, Self::Asset>, + settings: &Self::Settings, ) -> impl ConditionalSendFuture< Output = Result<::Settings, Self::Error>, >; @@ -38,7 +38,7 @@ pub trait AssetSaver: Send + Sync + 'static { /// A type-erased dynamic variant of [`AssetSaver`] that allows callers to save assets without knowing the actual type of the [`AssetSaver`]. pub trait ErasedAssetSaver: Send + Sync + 'static { /// Saves the given runtime [`ErasedLoadedAsset`] by writing it to a byte format using `writer`. The passed in `settings` can influence how the - /// `asset` is saved. + /// `asset` is saved. fn save<'a>( &'a self, writer: &'a mut Writer, diff --git a/crates/bevy_asset/src/server/info.rs b/crates/bevy_asset/src/server/info.rs index 1371d0fe02..fdeaaff089 100644 --- a/crates/bevy_asset/src/server/info.rs +++ b/crates/bevy_asset/src/server/info.rs @@ -282,7 +282,7 @@ impl AssetInfos { pub(crate) fn get_path_and_type_id_handle( &self, - path: &AssetPath, + path: &AssetPath<'_>, type_id: TypeId, ) -> Option { let id = self.path_to_id.get(path)?.get(&type_id)?; @@ -291,7 +291,7 @@ impl AssetInfos { pub(crate) fn get_path_ids<'a>( &'a self, - path: &'a AssetPath<'a>, + path: &'a AssetPath<'_>, ) -> impl Iterator + 'a { /// Concrete type to allow returning an `impl Iterator` even if `self.path_to_id.get(&path)` is `None` enum HandlesByPathIterator { @@ -322,7 +322,7 @@ impl AssetInfos { pub(crate) fn get_path_handles<'a>( &'a self, - path: &'a AssetPath<'a>, + path: &'a AssetPath<'_>, ) -> impl Iterator + 'a { self.get_path_ids(path) .filter_map(|id| self.get_id_handle(id)) diff --git a/crates/bevy_asset/src/server/loaders.rs b/crates/bevy_asset/src/server/loaders.rs index 64d26d4395..8c63a2306e 100644 --- a/crates/bevy_asset/src/server/loaders.rs +++ b/crates/bevy_asset/src/server/loaders.rs @@ -311,11 +311,11 @@ impl AssetLoader for InstrumentedAssetLoader { type Settings = T::Settings; type Error = T::Error; - fn load<'a>( - &'a self, - reader: &'a mut dyn crate::io::Reader, - settings: &'a Self::Settings, - load_context: &'a mut crate::LoadContext, + fn load( + &self, + reader: &mut dyn crate::io::Reader, + settings: &Self::Settings, + load_context: &mut crate::LoadContext, ) -> impl ConditionalSendFuture> { let span = info_span!( "asset loading", @@ -383,11 +383,11 @@ mod tests { type Error = String; - async fn load<'a>( - &'a self, - _: &'a mut dyn crate::io::Reader, - _: &'a Self::Settings, - _: &'a mut crate::LoadContext<'_>, + async fn load( + &self, + _: &mut dyn crate::io::Reader, + _: &Self::Settings, + _: &mut crate::LoadContext<'_>, ) -> Result { self.sender.send(()).unwrap(); diff --git a/crates/bevy_asset/src/server/mod.rs b/crates/bevy_asset/src/server/mod.rs index a527a7bd2a..9d57808ed0 100644 --- a/crates/bevy_asset/src/server/mod.rs +++ b/crates/bevy_asset/src/server/mod.rs @@ -131,10 +131,10 @@ impl AssetServer { } /// Retrieves the [`AssetSource`] for the given `source`. - pub fn get_source<'a, 'b>( - &'a self, - source: impl Into>, - ) -> Result<&'a AssetSource, MissingAssetSourceError> { + pub fn get_source<'a>( + &self, + source: impl Into>, + ) -> Result<&AssetSource, MissingAssetSourceError> { self.data.sources.get(source.into()) } @@ -218,9 +218,9 @@ impl AssetServer { } /// Retrieves the default [`AssetLoader`] for the given path, if one can be found. - pub async fn get_path_asset_loader<'a, 'b>( + pub async fn get_path_asset_loader<'a>( &self, - path: impl Into>, + path: impl Into>, ) -> Result, MissingAssetLoaderForExtensionError> { let path = path.into(); @@ -245,7 +245,7 @@ impl AssetServer { } /// Retrieves the default [`AssetLoader`] for the given [`Asset`] [`TypeId`], if one can be found. - pub async fn get_asset_loader_with_asset_type_id<'a>( + pub async fn get_asset_loader_with_asset_type_id( &self, type_id: TypeId, ) -> Result, MissingAssetLoaderForTypeIdError> { @@ -257,7 +257,7 @@ impl AssetServer { } /// Retrieves the default [`AssetLoader`] for the given [`Asset`] type, if one can be found. - pub async fn get_asset_loader_with_asset_type<'a, A: Asset>( + pub async fn get_asset_loader_with_asset_type( &self, ) -> Result, MissingAssetLoaderForTypeIdError> { self.get_asset_loader_with_asset_type_id(TypeId::of::()) diff --git a/crates/bevy_audio/src/audio_source.rs b/crates/bevy_audio/src/audio_source.rs index 7462ddf8a4..9cf3ca988b 100644 --- a/crates/bevy_audio/src/audio_source.rs +++ b/crates/bevy_audio/src/audio_source.rs @@ -42,11 +42,11 @@ impl AssetLoader for AudioLoader { type Settings = (); type Error = std::io::Error; - async fn load<'a>( - &'a self, - reader: &'a mut dyn Reader, - _settings: &'a Self::Settings, - _load_context: &'a mut LoadContext<'_>, + async fn load( + &self, + reader: &mut dyn Reader, + _settings: &Self::Settings, + _load_context: &mut LoadContext<'_>, ) -> Result { let mut bytes = Vec::new(); reader.read_to_end(&mut bytes).await?; @@ -111,7 +111,7 @@ pub trait AddAudioSource { /// so that it can be converted to a [`rodio::Source`] type, /// and [`Asset`], so that it can be registered as an asset. /// To use this method on [`App`][bevy_app::App], - /// the [audio][super::AudioPlugin] and [asset][bevy_asset::AssetPlugin] plugins must be added first. + /// the [audio][super::AudioPlugin] and [asset][bevy_asset::AssetPlugin] plugins must be added first. fn add_audio_source(&mut self) -> &mut Self where T: Decodable + Asset, diff --git a/crates/bevy_gltf/src/loader.rs b/crates/bevy_gltf/src/loader.rs index 1be494679a..0148651f88 100644 --- a/crates/bevy_gltf/src/loader.rs +++ b/crates/bevy_gltf/src/loader.rs @@ -179,11 +179,11 @@ impl AssetLoader for GltfLoader { type Asset = Gltf; type Settings = GltfLoaderSettings; type Error = GltfError; - async fn load<'a>( - &'a self, - reader: &'a mut dyn Reader, - settings: &'a GltfLoaderSettings, - load_context: &'a mut LoadContext<'_>, + async fn load( + &self, + reader: &mut dyn Reader, + settings: &GltfLoaderSettings, + load_context: &mut LoadContext<'_>, ) -> Result { let mut bytes = Vec::new(); reader.read_to_end(&mut bytes).await?; diff --git a/crates/bevy_pbr/src/meshlet/asset.rs b/crates/bevy_pbr/src/meshlet/asset.rs index dff1df292e..87e3483d0f 100644 --- a/crates/bevy_pbr/src/meshlet/asset.rs +++ b/crates/bevy_pbr/src/meshlet/asset.rs @@ -93,11 +93,11 @@ impl AssetSaver for MeshletMeshSaverLoader { type OutputLoader = Self; type Error = MeshletMeshSaveOrLoadError; - async fn save<'a>( - &'a self, - writer: &'a mut Writer, - asset: SavedAsset<'a, MeshletMesh>, - _settings: &'a (), + async fn save( + &self, + writer: &mut Writer, + asset: SavedAsset<'_, MeshletMesh>, + _settings: &(), ) -> Result<(), MeshletMeshSaveOrLoadError> { // Write asset magic number writer @@ -127,11 +127,11 @@ impl AssetLoader for MeshletMeshSaverLoader { type Settings = (); type Error = MeshletMeshSaveOrLoadError; - async fn load<'a>( - &'a self, - reader: &'a mut dyn Reader, - _settings: &'a (), - _load_context: &'a mut LoadContext<'_>, + async fn load( + &self, + reader: &mut dyn Reader, + _settings: &(), + _load_context: &mut LoadContext<'_>, ) -> Result { // Load and check magic number let magic = async_read_u64(reader).await?; diff --git a/crates/bevy_render/src/render_resource/shader.rs b/crates/bevy_render/src/render_resource/shader.rs index 7cb8b8f9ee..c6c37c6a62 100644 --- a/crates/bevy_render/src/render_resource/shader.rs +++ b/crates/bevy_render/src/render_resource/shader.rs @@ -259,11 +259,11 @@ impl AssetLoader for ShaderLoader { type Asset = Shader; type Settings = (); type Error = ShaderLoaderError; - async fn load<'a>( - &'a self, - reader: &'a mut dyn Reader, - _settings: &'a Self::Settings, - load_context: &'a mut LoadContext<'_>, + async fn load( + &self, + reader: &mut dyn Reader, + _settings: &Self::Settings, + load_context: &mut LoadContext<'_>, ) -> Result { let ext = load_context.path().extension().unwrap().to_str().unwrap(); let path = load_context.asset_path().to_string(); diff --git a/crates/bevy_render/src/texture/compressed_image_saver.rs b/crates/bevy_render/src/texture/compressed_image_saver.rs index 0ab053df33..3031e310af 100644 --- a/crates/bevy_render/src/texture/compressed_image_saver.rs +++ b/crates/bevy_render/src/texture/compressed_image_saver.rs @@ -19,11 +19,11 @@ impl AssetSaver for CompressedImageSaver { type OutputLoader = ImageLoader; type Error = CompressedImageSaverError; - async fn save<'a>( - &'a self, - writer: &'a mut bevy_asset::io::Writer, - image: SavedAsset<'a, Self::Asset>, - _settings: &'a Self::Settings, + async fn save( + &self, + writer: &mut bevy_asset::io::Writer, + image: SavedAsset<'_, Self::Asset>, + _settings: &Self::Settings, ) -> Result { let is_srgb = image.texture_descriptor.format.is_srgb(); diff --git a/crates/bevy_render/src/texture/exr_texture_loader.rs b/crates/bevy_render/src/texture/exr_texture_loader.rs index 8a8fd8c946..ddab1b58e9 100644 --- a/crates/bevy_render/src/texture/exr_texture_loader.rs +++ b/crates/bevy_render/src/texture/exr_texture_loader.rs @@ -35,11 +35,11 @@ impl AssetLoader for ExrTextureLoader { type Settings = ExrTextureLoaderSettings; type Error = ExrTextureLoaderError; - async fn load<'a>( - &'a self, - reader: &'a mut dyn Reader, - settings: &'a Self::Settings, - _load_context: &'a mut LoadContext<'_>, + async fn load( + &self, + reader: &mut dyn Reader, + settings: &Self::Settings, + _load_context: &mut LoadContext<'_>, ) -> Result { let format = TextureFormat::Rgba32Float; debug_assert_eq!( diff --git a/crates/bevy_render/src/texture/hdr_texture_loader.rs b/crates/bevy_render/src/texture/hdr_texture_loader.rs index ab5624fa08..08d907981f 100644 --- a/crates/bevy_render/src/texture/hdr_texture_loader.rs +++ b/crates/bevy_render/src/texture/hdr_texture_loader.rs @@ -30,11 +30,11 @@ impl AssetLoader for HdrTextureLoader { type Asset = Image; type Settings = HdrTextureLoaderSettings; type Error = HdrTextureLoaderError; - async fn load<'a>( - &'a self, - reader: &'a mut dyn Reader, - settings: &'a Self::Settings, - _load_context: &'a mut LoadContext<'_>, + async fn load( + &self, + reader: &mut dyn Reader, + settings: &Self::Settings, + _load_context: &mut LoadContext<'_>, ) -> Result { let format = TextureFormat::Rgba32Float; debug_assert_eq!( diff --git a/crates/bevy_render/src/texture/image_loader.rs b/crates/bevy_render/src/texture/image_loader.rs index c671108e58..c82c64807b 100644 --- a/crates/bevy_render/src/texture/image_loader.rs +++ b/crates/bevy_render/src/texture/image_loader.rs @@ -86,11 +86,11 @@ impl AssetLoader for ImageLoader { type Asset = Image; type Settings = ImageLoaderSettings; type Error = ImageLoaderError; - async fn load<'a>( - &'a self, - reader: &'a mut dyn Reader, - settings: &'a ImageLoaderSettings, - load_context: &'a mut LoadContext<'_>, + async fn load( + &self, + reader: &mut dyn Reader, + settings: &ImageLoaderSettings, + load_context: &mut LoadContext<'_>, ) -> Result { let mut bytes = Vec::new(); reader.read_to_end(&mut bytes).await?; diff --git a/crates/bevy_scene/src/scene_loader.rs b/crates/bevy_scene/src/scene_loader.rs index 200fb2d7ea..481b7ebc04 100644 --- a/crates/bevy_scene/src/scene_loader.rs +++ b/crates/bevy_scene/src/scene_loader.rs @@ -46,11 +46,11 @@ impl AssetLoader for SceneLoader { type Settings = (); type Error = SceneLoaderError; - async fn load<'a>( - &'a self, - reader: &'a mut dyn Reader, - _settings: &'a (), - _load_context: &'a mut LoadContext<'_>, + async fn load( + &self, + reader: &mut dyn Reader, + _settings: &(), + _load_context: &mut LoadContext<'_>, ) -> Result { let mut bytes = Vec::new(); reader.read_to_end(&mut bytes).await?; diff --git a/crates/bevy_text/src/font_loader.rs b/crates/bevy_text/src/font_loader.rs index 999e7fa75a..9e0f2185a2 100644 --- a/crates/bevy_text/src/font_loader.rs +++ b/crates/bevy_text/src/font_loader.rs @@ -22,11 +22,11 @@ impl AssetLoader for FontLoader { type Asset = Font; type Settings = (); type Error = FontLoaderError; - async fn load<'a>( - &'a self, - reader: &'a mut dyn Reader, - _settings: &'a (), - _load_context: &'a mut LoadContext<'_>, + async fn load( + &self, + reader: &mut dyn Reader, + _settings: &(), + _load_context: &mut LoadContext<'_>, ) -> Result { let mut bytes = Vec::new(); reader.read_to_end(&mut bytes).await?; diff --git a/examples/asset/asset_decompression.rs b/examples/asset/asset_decompression.rs index 65aa97d899..e961bc976c 100644 --- a/examples/asset/asset_decompression.rs +++ b/examples/asset/asset_decompression.rs @@ -39,11 +39,12 @@ impl AssetLoader for GzAssetLoader { type Asset = GzAsset; type Settings = (); type Error = GzAssetLoaderError; - async fn load<'a>( - &'a self, - reader: &'a mut dyn Reader, - _settings: &'a (), - load_context: &'a mut LoadContext<'_>, + + async fn load( + &self, + reader: &mut dyn Reader, + _settings: &(), + load_context: &mut LoadContext<'_>, ) -> Result { let compressed_path = load_context.path(); let file_name = compressed_path diff --git a/examples/asset/custom_asset.rs b/examples/asset/custom_asset.rs index f534207062..45acc0d673 100644 --- a/examples/asset/custom_asset.rs +++ b/examples/asset/custom_asset.rs @@ -33,11 +33,11 @@ impl AssetLoader for CustomAssetLoader { type Asset = CustomAsset; type Settings = (); type Error = CustomAssetLoaderError; - async fn load<'a>( - &'a self, - reader: &'a mut dyn Reader, - _settings: &'a (), - _load_context: &'a mut LoadContext<'_>, + async fn load( + &self, + reader: &mut dyn Reader, + _settings: &(), + _load_context: &mut LoadContext<'_>, ) -> Result { let mut bytes = Vec::new(); reader.read_to_end(&mut bytes).await?; @@ -72,11 +72,11 @@ impl AssetLoader for BlobAssetLoader { type Settings = (); type Error = BlobAssetLoaderError; - async fn load<'a>( - &'a self, - reader: &'a mut dyn Reader, - _settings: &'a (), - _load_context: &'a mut LoadContext<'_>, + async fn load( + &self, + reader: &mut dyn Reader, + _settings: &(), + _load_context: &mut LoadContext<'_>, ) -> Result { info!("Loading Blob..."); let mut bytes = Vec::new(); diff --git a/examples/asset/processing/asset_processing.rs b/examples/asset/processing/asset_processing.rs index d2439dd0cc..1367f26f24 100644 --- a/examples/asset/processing/asset_processing.rs +++ b/examples/asset/processing/asset_processing.rs @@ -81,11 +81,11 @@ impl AssetLoader for TextLoader { type Asset = Text; type Settings = TextSettings; type Error = std::io::Error; - async fn load<'a>( - &'a self, - reader: &'a mut dyn Reader, - settings: &'a TextSettings, - _load_context: &'a mut LoadContext<'_>, + async fn load( + &self, + reader: &mut dyn Reader, + settings: &TextSettings, + _load_context: &mut LoadContext<'_>, ) -> Result { let mut bytes = Vec::new(); reader.read_to_end(&mut bytes).await?; @@ -135,11 +135,11 @@ impl AssetLoader for CoolTextLoader { type Settings = (); type Error = CoolTextLoaderError; - async fn load<'a>( - &'a self, - reader: &'a mut dyn Reader, - _settings: &'a Self::Settings, - load_context: &'a mut LoadContext<'_>, + async fn load( + &self, + reader: &mut dyn Reader, + _settings: &Self::Settings, + load_context: &mut LoadContext<'_>, ) -> Result { let mut bytes = Vec::new(); reader.read_to_end(&mut bytes).await?; @@ -211,11 +211,11 @@ impl AssetSaver for CoolTextSaver { type OutputLoader = TextLoader; type Error = std::io::Error; - async fn save<'a>( - &'a self, - writer: &'a mut Writer, - asset: SavedAsset<'a, Self::Asset>, - _settings: &'a Self::Settings, + async fn save( + &self, + writer: &mut Writer, + asset: SavedAsset<'_, Self::Asset>, + _settings: &Self::Settings, ) -> Result { writer.write_all(asset.text.as_bytes()).await?; Ok(TextSettings::default())