From 4855eaaff1f807394d5732eb8f0094002da85a0a Mon Sep 17 00:00:00 2001 From: "Sl@ny" Date: Thu, 26 Sep 2019 22:39:25 +0200 Subject: [PATCH] Migration to Rust 2018 --- Cargo.lock | 6 +++--- Cargo.toml | 3 ++- src/cgg_data_source.rs | 14 ++------------ src/data_source.rs | 15 +++------------ src/main.rs | 36 ++++++++++++------------------------ src/pb_data_source.rs | 13 +------------ 6 files changed, 23 insertions(+), 64 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 03c5b11..412f28a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -125,7 +125,7 @@ dependencies = [ "serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "simple_logger 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winreg 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winreg 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1475,7 +1475,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "winreg" -version = "0.6.0" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1659,5 +1659,5 @@ dependencies = [ "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -"checksum winreg 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "daf67b95d0b1bf421c4f11048d63110ca3719977169eec86396b614c8942b6e0" +"checksum winreg 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" diff --git a/Cargo.toml b/Cargo.toml index f315fc5..2026826 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,8 @@ [package] name = "cggitem_sets" version = "0.1.0" -authors = ["nyyu "] +authors = ["nyyu "] +edition = "2018" [dependencies] log = "0.4" diff --git a/src/cgg_data_source.rs b/src/cgg_data_source.rs index 2ef853b..c0bee42 100644 --- a/src/cgg_data_source.rs +++ b/src/cgg_data_source.rs @@ -1,21 +1,11 @@ -extern crate indexmap; -extern crate lazy_static; -extern crate log; -extern crate regex; -extern crate reqwest; -extern crate select; -extern crate serde; -extern crate serde_json; -extern crate simple_logger; -extern crate winreg; - use indexmap::IndexMap; use regex::Regex; use select::document::Document; use select::predicate::{Class, Name}; use serde_json::Value; +use lazy_static::{lazy_static}; -use data_source::DataSource; +use crate::data_source::DataSource; pub struct CGGDataSource; impl DataSource for CGGDataSource { diff --git a/src/data_source.rs b/src/data_source.rs index be9cb84..6264ec7 100644 --- a/src/data_source.rs +++ b/src/data_source.rs @@ -1,18 +1,9 @@ -extern crate indexmap; -extern crate lazy_static; -extern crate log; -extern crate regex; -extern crate reqwest; -extern crate select; -extern crate serde; -extern crate serde_json; -extern crate simple_logger; -extern crate winreg; - use indexmap::IndexMap; -use serde_json::Value; +use serde_json::{Value, json}; use std::fs; use std::path::PathBuf; +use log::{info, error}; +use serde_derive::{Serialize, Deserialize}; #[derive(Serialize, Deserialize)] struct ItemSet { diff --git a/src/main.rs b/src/main.rs index d29ae3f..d25899c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,33 +1,21 @@ -#[macro_use] -extern crate serde_derive; -#[macro_use] -extern crate log; -extern crate reqwest; -extern crate serde; -#[macro_use] -extern crate serde_json; -extern crate regex; -extern crate select; -extern crate simple_logger; -#[macro_use] -extern crate lazy_static; -extern crate indexmap; -extern crate winreg; - -mod cgg_data_source; -mod data_source; -mod pb_data_source; - -use cgg_data_source::CGGDataSource; -use data_source::DataSource; use indexmap::IndexMap; -use pb_data_source::PBDataSource; use reqwest::header; use std::io::{Error, ErrorKind}; use std::path::PathBuf; use std::{fs, thread, time}; use time::Duration; use winreg::RegKey; +use simple_logger; +use log::{info, error}; +use serde_derive::{Deserialize}; + +mod cgg_data_source; +mod data_source; +mod pb_data_source; + +use cgg_data_source::CGGDataSource; +use pb_data_source::PBDataSource; +use data_source::DataSource; #[derive(Deserialize)] struct Realm { @@ -90,7 +78,7 @@ fn main() { .unwrap(); info!("LoL numbers of champs: {}", champion.data.len()); - let data_sources: [Box; 2] = [Box::new(PBDataSource), Box::new(CGGDataSource)]; + let data_sources: [Box; 2] = [Box::new(PBDataSource), Box::new(CGGDataSource)]; for data_source in data_sources.iter() { let (champs, patch) = data_source.get_champs_with_positions_and_patch(&client); diff --git a/src/pb_data_source.rs b/src/pb_data_source.rs index 0b6a32c..bf21341 100644 --- a/src/pb_data_source.rs +++ b/src/pb_data_source.rs @@ -1,18 +1,7 @@ -extern crate indexmap; -extern crate lazy_static; -extern crate log; -extern crate regex; -extern crate reqwest; -extern crate select; -extern crate serde; -extern crate serde_json; -extern crate simple_logger; -extern crate winreg; - use indexmap::IndexMap; use serde_json::Value; -use data_source::DataSource; +use crate::data_source::DataSource; pub struct PBDataSource; impl DataSource for PBDataSource {