mirror of https://github.com/MingweiSamuel/Riven
Convert Season from enum to newtype_enum
parent
4b23f9afed
commit
62e2001457
|
@ -6,11 +6,13 @@
|
||||||
// //
|
// //
|
||||||
///////////////////////////////////////////////
|
///////////////////////////////////////////////
|
||||||
|
|
||||||
|
use serde::{ Serialize, Deserialize };
|
||||||
|
|
||||||
newtype_enum! {
|
newtype_enum! {
|
||||||
/// A League of Legends season for competitive matchmaking.
|
/// A League of Legends season for competitive matchmaking.
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
#[serde(transparent)]
|
#[serde(transparent)]
|
||||||
pub newtype_enum Season {
|
pub newtype_enum Season(u8) {
|
||||||
PRESEASON_3 = 0,
|
PRESEASON_3 = 0,
|
||||||
SEASON_3 = 1,
|
SEASON_3 = 1,
|
||||||
PRESEASON_2014 = 2,
|
PRESEASON_2014 = 2,
|
||||||
|
@ -29,32 +31,3 @@ newtype_enum! {
|
||||||
SEASON_2020 = 15,
|
SEASON_2020 = 15,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use serde_repr::{ Serialize_repr, Deserialize_repr };
|
|
||||||
use num_enum::{ IntoPrimitive, TryFromPrimitive };
|
|
||||||
|
|
||||||
/// League of Legends matchmaking seasons.
|
|
||||||
#[non_exhaustive]
|
|
||||||
#[derive(Debug, Copy, Clone)]
|
|
||||||
#[derive(Eq, PartialEq, Hash, PartialOrd, Ord)]
|
|
||||||
#[derive(Serialize_repr, Deserialize_repr)]
|
|
||||||
#[derive(IntoPrimitive, TryFromPrimitive)]
|
|
||||||
#[repr(u8)]
|
|
||||||
pub enum Season2 {
|
|
||||||
PRESEASON_3 = 0,
|
|
||||||
SEASON_3 = 1,
|
|
||||||
PRESEASON_2014 = 2,
|
|
||||||
SEASON_2014 = 3,
|
|
||||||
PRESEASON_2015 = 4,
|
|
||||||
SEASON_2015 = 5,
|
|
||||||
PRESEASON_2016 = 6,
|
|
||||||
SEASON_2016 = 7,
|
|
||||||
PRESEASON_2017 = 8,
|
|
||||||
SEASON_2017 = 9,
|
|
||||||
PRESEASON_2018 = 10,
|
|
||||||
SEASON_2018 = 11,
|
|
||||||
PRESEASON_2019 = 12,
|
|
||||||
SEASON_2019 = 13,
|
|
||||||
PRESEASON_2020 = 14,
|
|
||||||
SEASON_2020 = 15,
|
|
||||||
}
|
|
||||||
|
|
|
@ -3,11 +3,13 @@
|
||||||
const seasons = require('./.seasons.json');
|
const seasons = require('./.seasons.json');
|
||||||
}}{{= dotUtils.preamble() }}
|
}}{{= dotUtils.preamble() }}
|
||||||
|
|
||||||
|
use serde::{ Serialize, Deserialize };
|
||||||
|
|
||||||
newtype_enum! {
|
newtype_enum! {
|
||||||
/// A League of Legends season for competitive matchmaking.
|
/// A League of Legends season for competitive matchmaking.
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
#[serde(transparent)]
|
#[serde(transparent)]
|
||||||
pub newtype_enum Season {
|
pub newtype_enum Season(u8) {
|
||||||
{{
|
{{
|
||||||
for (const e of seasons) {
|
for (const e of seasons) {
|
||||||
const desc = e['x-desc'] ? e['x-desc'].split('\n') : [];
|
const desc = e['x-desc'] ? e['x-desc'].split('\n') : [];
|
||||||
|
@ -21,27 +23,3 @@ newtype_enum! {
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use serde_repr::{ Serialize_repr, Deserialize_repr };
|
|
||||||
use num_enum::{ IntoPrimitive, TryFromPrimitive };
|
|
||||||
|
|
||||||
/// League of Legends matchmaking seasons.
|
|
||||||
#[non_exhaustive]
|
|
||||||
#[derive(Debug, Copy, Clone)]
|
|
||||||
#[derive(Eq, PartialEq, Hash, PartialOrd, Ord)]
|
|
||||||
#[derive(Serialize_repr, Deserialize_repr)]
|
|
||||||
#[derive(IntoPrimitive, TryFromPrimitive)]
|
|
||||||
#[repr(u8)]
|
|
||||||
pub enum Season2 {
|
|
||||||
{{
|
|
||||||
for (const e of seasons) {
|
|
||||||
const desc = e['x-desc'] ? e['x-desc'].split('\n') : [];
|
|
||||||
}}
|
|
||||||
{{~ desc :line }}
|
|
||||||
/// {{= line }}
|
|
||||||
{{~}}
|
|
||||||
{{= e['x-name'] }} = {{= e['x-value'] }},
|
|
||||||
{{
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue