fn match_role_with_database_roles(role: Role) -> StringExpand description
⚙️ Maps a Role enum value to its corresponding string representation as stored in the database.
This function takes a Role enum and converts it to a String that matches the format used in the database.
It is used to ensure consistency between the role representation in the code and the role names stored in the database.
§Parameters:
role: ARoleenum representing the role to be converted.
§Returns:
String: The corresponding string representation of the role (e.g., “Top”, “Jungler”).
§Example:
let role = Role::TOPLANE;
let role_str = match_role_with_database_roles(role);
assert_eq!(role_str, "Top");§⚠️ Notes:
- The function uses Rust’s
matchcontrol flow to convert eachRolevariant to the corresponding string. - This function is essential for ensuring compatibility between different parts of the code and the data storage layer.
§Related Enums:
Role: Represents different League of Legends roles likeTOPLANE,JUNGLE,MIDLANE, etc.
§See Also:
get_champions_by_role: Uses the string representation of a role to query the database for champions with that role.