forked from mirror/Riven
1
0
Fork 0

Convert Queue from enum to newtype_enum

users/mingwei/unknown-variant-messy
Mingwei Samuel 2021-06-30 19:44:24 -07:00
parent 2d80f97170
commit 35f826b198
2 changed files with 250 additions and 256 deletions

View File

@ -6,17 +6,13 @@
// //
///////////////////////////////////////////////
use serde_repr::{ Serialize_repr, Deserialize_repr };
use num_enum::{ IntoPrimitive, TryFromPrimitive };
use serde::{ Serialize, Deserialize };
/// League of Legends matchmaking queue.
#[non_exhaustive]
#[derive(Debug, Copy, Clone)]
#[derive(Eq, PartialEq)]
#[derive(Serialize_repr, Deserialize_repr)]
#[derive(IntoPrimitive, TryFromPrimitive)]
#[repr(u16)]
pub enum Queue {
newtype_enum! {
/// A League of Legends matchmaking queue.
#[derive(Serialize, Deserialize)]
#[serde(transparent)]
pub newtype_enum Queue(u16) {
/// Games on Custom games
CUSTOM = 0,
/// 5v5 Blind Pick games on Summoner's Rift
@ -247,4 +243,5 @@ pub enum Queue {
SUMMONERS_RIFT_TUTORIAL_2 = 2010,
/// Tutorial 3 games on Summoner's Rift
SUMMONERS_RIFT_TUTORIAL_3 = 2020,
}
}

View File

@ -3,17 +3,13 @@
const queues = require('./.queues.json');
}}{{= dotUtils.preamble() }}
use serde_repr::{ Serialize_repr, Deserialize_repr };
use num_enum::{ IntoPrimitive, TryFromPrimitive };
use serde::{ Serialize, Deserialize };
/// League of Legends matchmaking queue.
#[non_exhaustive]
#[derive(Debug, Copy, Clone)]
#[derive(Eq, PartialEq)]
#[derive(Serialize_repr, Deserialize_repr)]
#[derive(IntoPrimitive, TryFromPrimitive)]
#[repr(u16)]
pub enum Queue {
newtype_enum! {
/// A League of Legends matchmaking queue.
#[derive(Serialize, Deserialize)]
#[serde(transparent)]
pub newtype_enum Queue(u16) {
{{
for (const e of queues) {
const desc = e['x-desc'] ? e['x-desc'].split('\n') : [];
@ -29,4 +25,5 @@ pub enum Queue {
{{
}
}}
}
}