From 46dca4d55a9df9bb789e4ad7040e4a3b7937545b Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 2 Jan 2023 21:06:05 +0100 Subject: [PATCH] asset: make HandleUntyped::id private --- crates/bevy_asset/src/handle.rs | 9 +++++++-- examples/2d/texture_atlas.rs | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/crates/bevy_asset/src/handle.rs b/crates/bevy_asset/src/handle.rs index 677f1e053e10f..dfa4bd2d35892 100644 --- a/crates/bevy_asset/src/handle.rs +++ b/crates/bevy_asset/src/handle.rs @@ -322,8 +322,7 @@ impl Clone for Handle { /// To convert back to a typed handle, use the [typed](HandleUntyped::typed) method. #[derive(Debug)] pub struct HandleUntyped { - /// An unique identifier to an Asset. - pub id: HandleId, + id: HandleId, handle_type: HandleType, } @@ -352,6 +351,12 @@ impl HandleUntyped { } } + /// The ID of the asset. + #[inline] + pub fn id(&self) -> HandleId { + self.id + } + /// Creates a weak copy of this handle. #[must_use] pub fn clone_weak(&self) -> Self { diff --git a/examples/2d/texture_atlas.rs b/examples/2d/texture_atlas.rs index be41577cc5765..14d9119ebe0e1 100644 --- a/examples/2d/texture_atlas.rs +++ b/examples/2d/texture_atlas.rs @@ -34,8 +34,8 @@ fn check_textures( rpg_sprite_handles: ResMut, asset_server: Res, ) { - if let LoadState::Loaded = - asset_server.get_group_load_state(rpg_sprite_handles.handles.iter().map(|handle| handle.id)) + if let LoadState::Loaded = asset_server + .get_group_load_state(rpg_sprite_handles.handles.iter().map(|handle| handle.id())) { state.set(AppState::Finished).unwrap(); }