Skip to main content

battler_data/datastore/
aliases.rs

1use alloc::string::String;
2
3use hashbrown::HashMap;
4
5use crate::Id;
6
7/// A user-defined set of aliases.
8pub type SerializedAliases = HashMap<String, String>;
9
10/// Map of one ID to another.
11///
12/// The key represents the alias. The value should be a non-alias ID.
13pub type Aliases = HashMap<Id, Id>;
14
15/// Converts [`SerializedAliases`] into [`Aliases`].
16pub fn deserialize_aliases(aliases: SerializedAliases) -> Aliases {
17    aliases
18        .into_iter()
19        .map(|(a, b)| (Id::from(a), Id::from(b)))
20        .collect()
21}