Convert Queue from enum to newtype_enum

This commit is contained in:
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
@ -248,3 +244,4 @@ pub enum Queue {
/// 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') : [];
@ -30,3 +26,4 @@ pub enum Queue {
}
}}
}
}