diff --git a/Cargo.toml b/Cargo.toml index 90a7cde..3f4d3d9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,11 +34,11 @@ reqwest = { version = "0.10.0", default-features = false, features = ["rustls-tl tokio = { version = "0.2.9", features = ["rt-core", "process", "time"] } futures = "0.3.2" percent-encoding = "1.0" -lazy_static = "1.1" -encoding = "0.2.33" -filetime = "0.2.1" +lazy_static = "1.4" +encoding = "0.2.33" # or replace with encoding_rs +filetime = "0.2.8" chardet = "0.2.3" -chrono = "0.4.6" -regex = "1.0.5" -rayon = "1.0" +chrono = "0.4.8" +regex = "1.3" +rayon = "1.3" zip = "0.5" diff --git a/build.rs b/build.rs index a4cf980..c010405 100644 --- a/build.rs +++ b/build.rs @@ -32,7 +32,7 @@ fn fun() -> String { .unwrap_or_default(); let version = format!("{} ({}{})", env!("CARGO_PKG_VERSION"), git, date_time()); - format!("pub const VERSION: &'static str = \"{}\";", version) + format!("pub const VERSION: &str = \"{}\";", version) } // date --help @@ -73,5 +73,5 @@ fn decode_utf8_unchecked(bytes: Vec) -> String { fn decode(bytes: &[u8]) -> String { encoding_from_whatwg_label(charset2encoding(&detect(bytes).0)) .and_then(|code| code.decode(bytes, DecoderTrap::Strict).ok()) - .unwrap_or_else(|| String::from_utf8_lossy(bytes).into_owned().to_owned()) + .unwrap_or_else(|| String::from_utf8_lossy(bytes).into_owned()) } diff --git a/src/args.rs b/src/args.rs index 5b5f081..d83cbc1 100644 --- a/src/args.rs +++ b/src/args.rs @@ -240,19 +240,19 @@ impl<'app, 's: 'app> OptValueParse<'app> for &'s mut CharSet { if *count == 0 || typo.is_covered() || typo.is_multiple() { match CharSet::new(msg) { Err(_) => { - Err(format!("OPTION(<{}>) parse fails: \"{}\"", opt_name, msg))?; + return Err(format!("OPTION(<{}>) parse fails: \"{}\"", opt_name, msg)); } Ok(o) => **self = o, } } else if typo.is_single() { - Err(format!("OPTION(<{}>) can only occurs once, but second: {:?}", opt_name, msg))?; + return Err(format!("OPTION(<{}>) can only occurs once, but second: {:?}", opt_name, msg)); } Ok(()) } /// env::arg could is `""` fn check(&self, opt_name: &str, optional: &bool, count: &usize, _: &OptTypo) -> Result<(), String> { if !optional && *count == 0 && self.default().is_none() { - Err(format!("OPTION(<{}>) missing", opt_name))?; + return Err(format!("OPTION(<{}>) missing", opt_name)); } Ok(()) } diff --git a/src/coll/ip.rs b/src/coll/ip.rs index 15229d6..477b48a 100644 --- a/src/coll/ip.rs +++ b/src/coll/ip.rs @@ -4,13 +4,14 @@ use reqwest::{header, Client}; use crate::consts::basic_runtime; use std::time::Duration; -static HOSTS: &'static [&str] = &["https://ip.cn/", "https://myip.ipip.net/", "https://ipinfo.io/"]; +static HOSTS: &[&str] = &["https://ip.cn/", "https://myip.ipip.net/", "https://ipinfo.io/"]; // curl https://ip.cn -v -static UA: &'static str = "curl/7.54.0"; -static ACCEPT: &'static str = "Accept: */*"; +static UA: &str = "curl/7.54.0"; +static ACCEPT: &str = "Accept: */*"; pub fn call() { let mut rt = basic_runtime(); + let mut headers = header::HeaderMap::new(); headers.insert(header::USER_AGENT, UA.parse().unwrap()); headers.insert(header::ACCEPT, ACCEPT.parse().unwrap()); diff --git a/src/coll/ping/ping.rs b/src/coll/ping/ping.rs index 06e61e3..6af967b 100644 --- a/src/coll/ping/ping.rs +++ b/src/coll/ping/ping.rs @@ -183,12 +183,12 @@ fn printf_err(msg: &Output, host: &str, host_len_max: usize) { // #[cfg(unix)] // fn decode(msg: &[u8]) -> String { -// String::from_utf8_lossy(msg).into_owned().to_owned() +// String::from_utf8_lossy(msg).into_owned() // } // #[cfg(windows)] fn decode(bytes: &[u8]) -> String { encoding_from_whatwg_label(charset2encoding(&detect(bytes).0)) .and_then(|code| code.decode(bytes, DecoderTrap::Strict).ok()) - .unwrap_or_else(|| String::from_utf8_lossy(bytes).into_owned().to_owned()) + .unwrap_or_else(|| String::from_utf8_lossy(bytes).into_owned()) } diff --git a/src/coll/unzip.rs b/src/coll/unzip.rs index b976ea3..798f48e 100644 --- a/src/coll/unzip.rs +++ b/src/coll/unzip.rs @@ -144,10 +144,10 @@ fn for_zip_arch_file(zip_arch_path: &str, config: &Zips) -> Result<(), ZipCSErro let dir_item = read_dir(&outdir_path) .map_err(|e| format!("Reading OutDir({}) occurs error: {}", outdir_path.display(), e.description()))?; if dir_item.count() != 0 { - Err(format!("OutDir({}) is not empty!", outdir_path.display()))?; + return Err(format!("OutDir({}) is not empty!", outdir_path.display()).into()); } } else if outdir_path.exists() && !outdir_path.is_dir() { - Err(format!("OutDir({}) is not a Dir!", outdir_path.display()))?; + return Err(format!("OutDir({}) is not a Dir!", outdir_path.display()).into()); } else { create_dir_all(outdir_path)?; } diff --git a/src/consts.rs b/src/consts.rs index 8b6d467..cc890d4 100644 --- a/src/consts.rs +++ b/src/consts.rs @@ -1,17 +1,17 @@ #![allow(unknown_lints, const_static_lifetime)] // crate's info -pub const NAME: &'static str = env!("CARGO_PKG_NAME"); -// pub const VERSION: &'static str = env!("CARGO_PKG_VERSION"); +pub const NAME: &str = env!("CARGO_PKG_NAME"); +// pub const VERSION: &str = env!("CARGO_PKG_VERSION"); include!(concat!(env!("OUT_DIR"), "/zipcs.txt")); -pub const AUTHOR: &'static str = "Wspsxing"; -pub const EMAIL: &'static str = "biluohc@qq.com"; -pub const DESC: &'static str = env!("CARGO_PKG_DESCRIPTION"); +pub const AUTHOR: &str = "Wspsxing"; +pub const EMAIL: &str = "biluohc@qq.com"; +pub const DESC: &str = env!("CARGO_PKG_DESCRIPTION"); -pub const URL_NAME: &'static str = "Repo"; -pub const URL: &'static str = "https://github.com/biluohc/zipcs"; +pub const URL_NAME: &str = "Repo"; +pub const URL: &str = "https://github.com/biluohc/zipcs"; // copy form use@line16 ,but BIG5_2003 is swap by big5. -pub const CHARSETS: &'static str = "UTF_8, UTF_16BE, UTF_16LE, GBK, GB18030, HZ, BIG5..."; +pub const CHARSETS: &str = "UTF_8, UTF_16BE, UTF_16LE, GBK, GB18030, HZ, BIG5..."; pub fn space_fix(msg: &str, msg_len_max: usize) -> String { let mut str = msg.to_owned();