Skip to content
This repository was archived by the owner on Dec 10, 2022. It is now read-only.

Commit 78ad43a

Browse files
committed
refactor(clippy): fix warnings
1 parent a63d604 commit 78ad43a

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fn version() -> u32 {
6767
assert!(major < 1000, "Invalid major version");
6868
assert!(minor < 1000, "Invalid minor version");
6969
assert!(patch < 1000, "Invalid patch version");
70-
3000000000 + major * 1000000 + minor * 1000 + patch
70+
3_000_000_000 + major * 1_000_000 + minor * 1000 + patch
7171
}
7272

7373
/// Bind a UDP listener to the socket address.
@@ -304,7 +304,7 @@ fn main() {
304304
LogType::None => { },
305305
}
306306

307-
for (key, _) in &config.unused {
307+
for key in config.unused.keys() {
308308
warn!("Unused configuration key: {:?}", key);
309309
}
310310

src/motd.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ impl Motd {
8585
fn summary(source: u64) -> String {
8686
match source {
8787
0..=999 => format!("{}",source),
88-
1000..=999999 => format!("{0:.1}K", source as f32 / 1000.0),
89-
1000000..=999999999 => format!("{0:.1}M", source as f32 / 1000000.0),
90-
1000000000..=999999999999 => format!("{0:.1}G", source as f32 / 1000000000.0),
91-
1000000000000..=u64::MAX => format!("{0:.1}T", source as f32 / 1000000000000.0),
88+
1_000..=999_999 => format!("{0:.1}K", source as f32 / 1_000.0),
89+
1_000_000..=999_999_999 => format!("{0:.1}M", source as f32 / 1_000_000.0),
90+
1_000_000_000..=999_999_999_999 => format!("{0:.1}G", source as f32 / 1_000_000_000.0),
91+
1_000_000_000_000..=u64::MAX => format!("{0:.1}T", source as f32 / 1_000_000_000_000.0),
9292
_ => unreachable!("Packets counter has an impossible value")
9393
}
9494
}

src/node_config.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ fn de_from_hex<'de, D>(deserializer: D) -> Result<PublicKey, D::Error> where D:
7676
let bootstrap_pk_bytes: [u8; 32] = FromHex::from_hex(s)
7777
.map_err(|e| de::Error::custom(format!("Can't make bytes from hex string {:?}", e)))?;
7878
PublicKey::from_slice(&bootstrap_pk_bytes)
79-
.ok_or(de::Error::custom("Can't make PublicKey"))
79+
.ok_or_else(|| de::Error::custom("Can't make PublicKey"))
8080
}
8181

8282
// TODO: Remove this function. Use default String type after bug fix released.
@@ -259,18 +259,18 @@ pub fn cli_parse() -> NodeConfig {
259259
}
260260

261261
/// Parse settings from a saved file.
262-
fn parse_config(config_path: String) -> NodeConfig {
262+
fn parse_config(config_path: &str) -> NodeConfig {
263263
let mut settings = Config::default();
264264

265265
settings.set_default("log-type", "Stderr").expect("Can't set default value for `log-type`");
266266
settings.set_default("motd", "This is tox-rs").expect("Can't set default value for `motd`");
267267
settings.set_default("lan-discovery", "False").expect("Can't set default value for `lan-discovery`");
268268
settings.set_default("threads", "1").expect("Can't set default value for `threads`");
269269

270-
let config_file = if !Path::new(&config_path).exists() {
270+
let config_file = if !Path::new(config_path).exists() {
271271
panic!("Can't find config file {}", config_path);
272272
} else {
273-
CfgFile::with_name(&config_path)
273+
CfgFile::with_name(config_path)
274274
};
275275

276276
settings.merge(config_file).expect("Merging config file with default values failed");
@@ -287,7 +287,7 @@ fn parse_config(config_path: String) -> NodeConfig {
287287
fn run_config(matches: &ArgMatches) -> NodeConfig {
288288
let config_path = value_t!(matches.value_of("cfg-file"), String).unwrap_or_else(|e| e.exit());
289289

290-
parse_config(config_path)
290+
parse_config(&config_path)
291291
}
292292

293293
fn run_args(matches: &ArgMatches) -> NodeConfig {

0 commit comments

Comments
 (0)