mirror of
https://github.com/MingweiSamuel/Riven.git
synced 2024-12-27 03:16:33 +00:00
Convert Map from enum into newtype_enum
This commit is contained in:
parent
88124ecb3a
commit
2d80f97170
3 changed files with 62 additions and 68 deletions
|
@ -64,7 +64,7 @@ macro_rules! newtype_enum {
|
|||
} => {
|
||||
$( #[$attr] )*
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(PartialEq, Eq, PartialOrd, Ord)]
|
||||
#[derive(Hash, PartialEq, Eq, PartialOrd, Ord)]
|
||||
#[repr(transparent)]
|
||||
$v struct $name($v $repr);
|
||||
impl $name {
|
||||
|
|
|
@ -6,17 +6,13 @@
|
|||
// //
|
||||
///////////////////////////////////////////////
|
||||
|
||||
use serde_repr::{ Serialize_repr, Deserialize_repr };
|
||||
use num_enum::{ IntoPrimitive, TryFromPrimitive };
|
||||
use serde::{ Serialize, Deserialize };
|
||||
|
||||
/// League of Legends maps.
|
||||
#[non_exhaustive]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
#[derive(Eq, PartialEq, Hash, PartialOrd, Ord)]
|
||||
#[derive(Serialize_repr, Deserialize_repr)]
|
||||
#[derive(IntoPrimitive, TryFromPrimitive)]
|
||||
#[repr(u8)]
|
||||
pub enum Map {
|
||||
newtype_enum! {
|
||||
/// A League of Legends map.
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[serde(transparent)]
|
||||
pub newtype_enum Map(u8) {
|
||||
/// Summoner's Rift
|
||||
/// Original Summer variant
|
||||
SUMMONERS_RIFT_ORIGINAL_SUMMER_VARIANT = 1,
|
||||
|
@ -62,4 +58,5 @@ pub enum Map {
|
|||
/// Convergence
|
||||
/// Teamfight Tactics map
|
||||
CONVERGENCE = 22,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,17 +3,13 @@
|
|||
const maps = require('./.maps.json');
|
||||
}}{{= dotUtils.preamble() }}
|
||||
|
||||
use serde_repr::{ Serialize_repr, Deserialize_repr };
|
||||
use num_enum::{ IntoPrimitive, TryFromPrimitive };
|
||||
use serde::{ Serialize, Deserialize };
|
||||
|
||||
/// League of Legends maps.
|
||||
#[non_exhaustive]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
#[derive(Eq, PartialEq, Hash, PartialOrd, Ord)]
|
||||
#[derive(Serialize_repr, Deserialize_repr)]
|
||||
#[derive(IntoPrimitive, TryFromPrimitive)]
|
||||
#[repr(u8)]
|
||||
pub enum Map {
|
||||
newtype_enum! {
|
||||
/// A League of Legends map.
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[serde(transparent)]
|
||||
pub newtype_enum Map(u8) {
|
||||
{{
|
||||
for (const e of maps) {
|
||||
const desc = e['x-desc'] ? e['x-desc'].split('\n') : [];
|
||||
|
@ -25,4 +21,5 @@ pub enum Map {
|
|||
{{
|
||||
}
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue