mirror of https://github.com/MingweiSamuel/Riven
Convert Map from enum into newtype_enum
parent
88124ecb3a
commit
2d80f97170
|
@ -64,7 +64,7 @@ macro_rules! newtype_enum {
|
||||||
} => {
|
} => {
|
||||||
$( #[$attr] )*
|
$( #[$attr] )*
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
#[derive(PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Hash, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
$v struct $name($v $repr);
|
$v struct $name($v $repr);
|
||||||
impl $name {
|
impl $name {
|
||||||
|
|
|
@ -6,17 +6,13 @@
|
||||||
// //
|
// //
|
||||||
///////////////////////////////////////////////
|
///////////////////////////////////////////////
|
||||||
|
|
||||||
use serde_repr::{ Serialize_repr, Deserialize_repr };
|
use serde::{ Serialize, Deserialize };
|
||||||
use num_enum::{ IntoPrimitive, TryFromPrimitive };
|
|
||||||
|
|
||||||
/// League of Legends maps.
|
newtype_enum! {
|
||||||
#[non_exhaustive]
|
/// A League of Legends map.
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Serialize, Deserialize)]
|
||||||
#[derive(Eq, PartialEq, Hash, PartialOrd, Ord)]
|
#[serde(transparent)]
|
||||||
#[derive(Serialize_repr, Deserialize_repr)]
|
pub newtype_enum Map(u8) {
|
||||||
#[derive(IntoPrimitive, TryFromPrimitive)]
|
|
||||||
#[repr(u8)]
|
|
||||||
pub enum Map {
|
|
||||||
/// Summoner's Rift
|
/// Summoner's Rift
|
||||||
/// Original Summer variant
|
/// Original Summer variant
|
||||||
SUMMONERS_RIFT_ORIGINAL_SUMMER_VARIANT = 1,
|
SUMMONERS_RIFT_ORIGINAL_SUMMER_VARIANT = 1,
|
||||||
|
@ -63,3 +59,4 @@ pub enum Map {
|
||||||
/// Teamfight Tactics map
|
/// Teamfight Tactics map
|
||||||
CONVERGENCE = 22,
|
CONVERGENCE = 22,
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -3,17 +3,13 @@
|
||||||
const maps = require('./.maps.json');
|
const maps = require('./.maps.json');
|
||||||
}}{{= dotUtils.preamble() }}
|
}}{{= dotUtils.preamble() }}
|
||||||
|
|
||||||
use serde_repr::{ Serialize_repr, Deserialize_repr };
|
use serde::{ Serialize, Deserialize };
|
||||||
use num_enum::{ IntoPrimitive, TryFromPrimitive };
|
|
||||||
|
|
||||||
/// League of Legends maps.
|
newtype_enum! {
|
||||||
#[non_exhaustive]
|
/// A League of Legends map.
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Serialize, Deserialize)]
|
||||||
#[derive(Eq, PartialEq, Hash, PartialOrd, Ord)]
|
#[serde(transparent)]
|
||||||
#[derive(Serialize_repr, Deserialize_repr)]
|
pub newtype_enum Map(u8) {
|
||||||
#[derive(IntoPrimitive, TryFromPrimitive)]
|
|
||||||
#[repr(u8)]
|
|
||||||
pub enum Map {
|
|
||||||
{{
|
{{
|
||||||
for (const e of maps) {
|
for (const e of maps) {
|
||||||
const desc = e['x-desc'] ? e['x-desc'].split('\n') : [];
|
const desc = e['x-desc'] ? e['x-desc'].split('\n') : [];
|
||||||
|
@ -26,3 +22,4 @@ pub enum Map {
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue