forked from mirror/Riven
1
0
Fork 0

adding/switching to num_enum macros for enums

users/mingwei/surf
Mingwei Samuel 2019-10-26 09:23:58 -07:00
parent aa5f251964
commit df27e7533e
12 changed files with 26 additions and 9 deletions

View File

@ -12,8 +12,7 @@ include = [ "src/**/*" ]
[dependencies]
log = "0.4"
num-traits = "0.2"
num-derive = "0.3"
num_enum = "0.4"
parking_lot = { version = "0.9", features = [ "nightly" ] }
reqwest = { version = "0.10.0-alpha.1", features = [ "gzip", "json" ] }
scan_fmt = "0.2"

View File

@ -7,7 +7,7 @@
///////////////////////////////////////////////
use std::fmt;
use num_derive::{ FromPrimitive, ToPrimitive };
use num_enum::{ IntoPrimitive, TryFromPrimitive };
use serde_repr::{ Serialize_repr, Deserialize_repr };
/// League of Legend's champions.
@ -15,7 +15,7 @@ use serde_repr::{ Serialize_repr, Deserialize_repr };
/// The documentation of each variant specifies:<br>
/// NAME (`IDENTIFIER`, ID).
#[derive(Debug, Copy, Clone)]
#[derive(FromPrimitive, ToPrimitive)]
#[derive(IntoPrimitive, TryFromPrimitive)]
#[derive(Serialize_repr, Deserialize_repr)]
#[repr(i16)]
pub enum Champion {

View File

@ -2,11 +2,13 @@
use strum_macros::{ EnumString, Display, AsRefStr };
use serde_repr::{ Serialize_repr, Deserialize_repr };
use num_enum::{ IntoPrimitive, TryFromPrimitive };
#[derive(Debug, Copy, Clone)]
#[derive(Eq, PartialEq, Hash, PartialOrd, Ord)]
#[derive(EnumString, Display, AsRefStr)]
#[derive(Serialize_repr, Deserialize_repr)]
#[derive(IntoPrimitive, TryFromPrimitive)]
#[repr(u8)]
pub enum Division {
I = 1,

View File

@ -7,11 +7,13 @@
///////////////////////////////////////////////
use serde_repr::{ Serialize_repr, Deserialize_repr };
use num_enum::{ IntoPrimitive, TryFromPrimitive };
/// League of Legends maps.
#[derive(Debug, Copy, Clone)]
#[derive(Eq, PartialEq, Hash, PartialOrd, Ord)]
#[derive(Serialize_repr, Deserialize_repr)]
#[derive(IntoPrimitive, TryFromPrimitive)]
#[repr(u8)]
pub enum Map {

View File

@ -8,11 +8,13 @@
#![allow(deprecated)]
use serde_repr::{ Serialize_repr, Deserialize_repr };
use num_enum::{ IntoPrimitive, TryFromPrimitive };
/// League of Legends matchmaking queue.
#[derive(Debug, Copy, Clone)]
#[derive(Eq, PartialEq)]
#[derive(Serialize_repr, Deserialize_repr)]
#[derive(IntoPrimitive, TryFromPrimitive)]
#[repr(u16)]
pub enum Queue {

View File

@ -7,11 +7,13 @@
///////////////////////////////////////////////
use serde_repr::{ Serialize_repr, Deserialize_repr };
use num_enum::{ IntoPrimitive, TryFromPrimitive };
/// League of Legends matchmaking seasons.
#[derive(Debug, Copy, Clone)]
#[derive(Eq, PartialEq, Hash, PartialOrd, Ord)]
#[derive(Serialize_repr, Deserialize_repr)]
#[derive(IntoPrimitive, TryFromPrimitive)]
#[repr(u8)]
pub enum Season {
Preseason3 = 0,

View File

@ -1,9 +1,11 @@
use serde_repr::{ Serialize_repr, Deserialize_repr };
use num_enum::{ IntoPrimitive, TryFromPrimitive };
/// League of Legends team.
#[derive(Debug, Copy, Clone)]
#[derive(Eq, PartialEq, Hash, Ord, PartialOrd)]
#[derive(Serialize_repr, Deserialize_repr)]
#[derive(IntoPrimitive, TryFromPrimitive)]
#[repr(u8)]
pub enum Team {
/// Blue team (bottom left on Summoner's Rift).

View File

@ -1,10 +1,12 @@
#![allow(deprecated)]
use strum_macros::{ EnumString, Display, AsRefStr };
use num_enum::{ IntoPrimitive, TryFromPrimitive };
#[derive(Debug, Copy, Clone)]
#[derive(Eq, PartialEq, Hash, PartialOrd, Ord)]
#[derive(EnumString, Display, AsRefStr)]
#[derive(IntoPrimitive, TryFromPrimitive)]
#[repr(u8)]
pub enum Tier {
#[strum(to_string="IRON")] Iron = 40,
@ -13,9 +15,9 @@ pub enum Tier {
#[strum(to_string="GOLD")] Gold = 100,
#[strum(to_string="PLATINUM")] Platinum = 120,
#[strum(to_string="DIAMOND")] Diamond = 140,
#[strum(to_string="MASTER")] Master = 200,
#[strum(to_string="GRANDMASTER")] Grandmaster = 220,
#[strum(to_string="CHALLENGER")] Challenger = 240,
#[strum(to_string="MASTER")] Master = 180,
#[strum(to_string="GRANDMASTER")] Grandmaster = 200,
#[strum(to_string="CHALLENGER")] Challenger = 220,
}
serde_string!(Tier);

View File

@ -14,7 +14,7 @@
}}{{= require('./dotUtils.js').preamble() }}
use std::fmt;
use num_derive::{ FromPrimitive, ToPrimitive };
use num_enum::{ IntoPrimitive, TryFromPrimitive };
use serde_repr::{ Serialize_repr, Deserialize_repr };
/// League of Legend's champions.
@ -22,7 +22,7 @@ use serde_repr::{ Serialize_repr, Deserialize_repr };
/// The documentation of each variant specifies:<br>
/// NAME (`IDENTIFIER`, ID).
#[derive(Debug, Copy, Clone)]
#[derive(FromPrimitive, ToPrimitive)]
#[derive(IntoPrimitive, TryFromPrimitive)]
#[derive(Serialize_repr, Deserialize_repr)]
#[repr(i16)]
pub enum Champion {

View File

@ -6,11 +6,13 @@
}}{{= dotUtils.preamble() }}
use serde_repr::{ Serialize_repr, Deserialize_repr };
use num_enum::{ IntoPrimitive, TryFromPrimitive };
/// League of Legends maps.
#[derive(Debug, Copy, Clone)]
#[derive(Eq, PartialEq, Hash, PartialOrd, Ord)]
#[derive(Serialize_repr, Deserialize_repr)]
#[derive(IntoPrimitive, TryFromPrimitive)]
#[repr(u8)]
pub enum Map {
{{

View File

@ -11,11 +11,13 @@
#![allow(deprecated)]
use serde_repr::{ Serialize_repr, Deserialize_repr };
use num_enum::{ IntoPrimitive, TryFromPrimitive };
/// League of Legends matchmaking queue.
#[derive(Debug, Copy, Clone)]
#[derive(Eq, PartialEq)]
#[derive(Serialize_repr, Deserialize_repr)]
#[derive(IntoPrimitive, TryFromPrimitive)]
#[repr(u16)]
pub enum Queue {
{{

View File

@ -4,11 +4,13 @@
}}{{= dotUtils.preamble() }}
use serde_repr::{ Serialize_repr, Deserialize_repr };
use num_enum::{ IntoPrimitive, TryFromPrimitive };
/// League of Legends matchmaking seasons.
#[derive(Debug, Copy, Clone)]
#[derive(Eq, PartialEq, Hash, PartialOrd, Ord)]
#[derive(Serialize_repr, Deserialize_repr)]
#[derive(IntoPrimitive, TryFromPrimitive)]
#[repr(u8)]
pub enum Season {
{{