Skip to content

Commit

Permalink
Rename map key types to start with Asset
Browse files Browse the repository at this point in the history
  • Loading branch information
NiklasEi committed Feb 26, 2024
1 parent 3f1a132 commit f199acf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions bevy_asset_loader/examples/asset_maps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ struct AudioAssets {
full_path: HashMap<String, Handle<AudioSource>>,
// `FileName` as the key will use the file name (strip away any directories in the path)
#[asset(path = "audio", collection(mapped, typed))]
file_name: HashMap<FileName, Handle<AudioSource>>,
file_name: HashMap<AssetFileName, Handle<AudioSource>>,
// `FileStem` as the key will use the file name without the extension
#[asset(path = "audio", collection(mapped, typed))]
file_stem: HashMap<FileStem, Handle<AudioSource>>,
file_stem: HashMap<AssetFileStem, Handle<AudioSource>>,
// `AssetLabel` as the key uses the label (part after the `#` here)
// This will panic if an asset in the collection has no label!
#[asset(
Expand Down
2 changes: 1 addition & 1 deletion bevy_asset_loader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pub mod prelude {
DynamicAssets,
},
loading_state::{LoadingState, LoadingStateAppExt, LoadingStateSet},
mapped::{AssetLabel, FileName, FileStem, MapKey},
mapped::{AssetLabel, AssetFileName, AssetFileStem, MapKey},
};
}

Expand Down
16 changes: 8 additions & 8 deletions bevy_asset_loader/src/mapped.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ macro_rules! impl_map_key_extras {
///
/// # Key collision
///
/// Since [`FileName`] uses a subset of the asset path, two different assets may have the same key.
/// Since [`AssetFileName`] uses a subset of the asset path, two different assets may have the same key.
/// It’s up to you to ensure there is no collision.
///
/// Here's an example that will result in a key clash.
Expand All @@ -72,11 +72,11 @@ macro_rules! impl_map_key_extras {
///
/// [`file_name`]: std::path::Path::file_name
#[derive(Debug, Default, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct FileName(Box<str>);
pub struct AssetFileName(Box<str>);

impl_map_key_extras!(FileName);
impl_map_key_extras!(AssetFileName);

impl MapKey for FileName {
impl MapKey for AssetFileName {
#[inline]
fn from_asset_path(path: &AssetPath) -> Self {
Self(
Expand All @@ -94,7 +94,7 @@ impl MapKey for FileName {
///
/// # Key collision
///
/// Since [`FileStem`] uses a subset of the asset path, two different assets may have the same key.
/// Since [`AssetFileStem`] uses a subset of the asset path, two different assets may have the same key.
/// It’s up to you to ensure there is no collision.
///
/// Here's an example that will result in a key clash.
Expand All @@ -107,11 +107,11 @@ impl MapKey for FileName {
///
/// [`file_stem`]: std::path::Path::file_stem
#[derive(Debug, Default, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct FileStem(Box<str>);
pub struct AssetFileStem(Box<str>);

impl_map_key_extras!(FileStem);
impl_map_key_extras!(AssetFileStem);

impl MapKey for FileStem {
impl MapKey for AssetFileStem {
#[inline]
fn from_asset_path(path: &AssetPath) -> Self {
Self(
Expand Down

0 comments on commit f199acf

Please sign in to comment.