fix clippy

This commit is contained in:
2020-04-12 14:17:42 +08:00
parent 63919d5532
commit 2e70fc3d73
5 changed files with 18 additions and 18 deletions

View File

@@ -117,7 +117,7 @@ pub fn parse_config(config_json: &json::JsonValue) -> OSSBackupdConfig {
let mut items_objects: Vec<OSSBackupdConfigItem> = vec![];
if items.is_array() {
for i in 0..items.len() {
items_objects.push(parse_oss_backupd_config_item(&items[i], &root_oss_config_object, &encrypt_pubkey_file, &backup_count));
items_objects.push(parse_oss_backupd_config_item(&items[i], &root_oss_config_object, &encrypt_pubkey_file, backup_count));
}
}
@@ -142,16 +142,16 @@ pub fn get_config_json(custom_oss_backupd_config: Option<&str>, verbose: bool) -
fn remove_start_end_slash(s: &str) -> String {
let mut ss = s;
while ss.starts_with("/") {
while ss.starts_with('/') {
ss = &ss[1..]
}
while ss.ends_with("/") {
while ss.ends_with('/') {
ss = &ss[0..(ss.len() - 1)];
}
ss.to_owned()
}
fn parse_oss_backupd_config_item(item: &json::JsonValue, root_oss_config_object: &Option<OSSConfig>, root_encrypt_pubkey_file: &Option<String>, root_backup_count: &Option<u32>) -> OSSBackupdConfigItem {
fn parse_oss_backupd_config_item(item: &json::JsonValue, root_oss_config_object: &Option<OSSConfig>, root_encrypt_pubkey_file: &Option<String>, root_backup_count: Option<u32>) -> OSSBackupdConfigItem {
let target = get_string_value(item, "target");
let file_name = get_string_value(item, "file_name");
let mut backup_count = get_u32_value(item, "backup_count");
@@ -185,7 +185,7 @@ fn parse_oss_backupd_config_item(item: &json::JsonValue, root_oss_config_object:
encrypt_pubkey_file = root_encrypt_pubkey_file.clone();
}
if backup_count.is_none() && root_backup_count.is_some() {
backup_count = root_backup_count.clone();
backup_count = root_backup_count;
}
OSSBackupdConfigItem {
@@ -314,7 +314,7 @@ fn get_config_content(custom_oss_backupd_config: Option<&str>, verbose: bool) ->
fn get_user_home() -> XResult<String> {
match dirs::home_dir() {
None => Err(new_box_ioerror("Home dir not found!")),
Some(home_dir) => home_dir.to_str().map(|h| h.to_owned()).ok_or(new_box_ioerror("Home dir not found!")),
Some(home_dir) => home_dir.to_str().map(|h| h.to_owned()).ok_or_else(|| new_box_ioerror("Home dir not found!")),
}
}