Skip to content

Commit

Permalink
v0.3.7 cargo clippy and update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
biluohc committed Feb 8, 2020
1 parent b117075 commit ad81f03
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 26 deletions.
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 2 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -73,5 +73,5 @@ fn decode_utf8_unchecked(bytes: Vec<u8>) -> 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())
}
6 changes: 3 additions & 3 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<CharSet> fails: \"{}\"", opt_name, msg))?;
return Err(format!("OPTION(<{}>) parse<CharSet> 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(())
}
Expand Down
7 changes: 4 additions & 3 deletions src/coll/ip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions src/coll/ping/ping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
4 changes: 2 additions & 2 deletions src/coll/unzip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
}
Expand Down
16 changes: 8 additions & 8 deletions src/consts.rs
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]";
pub const DESC: &'static str = env!("CARGO_PKG_DESCRIPTION");
pub const AUTHOR: &str = "Wspsxing";
pub const EMAIL: &str = "[email protected]";
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();
Expand Down

0 comments on commit ad81f03

Please sign in to comment.