From d8d8af9826aff66dccb132a9d83e5a546795c0d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Tue, 19 Jan 2021 10:38:00 +0100 Subject: [PATCH] clippy: use chars / byte string literals MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabian Grünbichler --- src/api2/admin/datastore.rs | 6 +++--- src/backup/chunk_store.rs | 4 ++-- src/backup/datastore.rs | 2 +- src/config/network.rs | 2 +- src/tools/subscription.rs | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs index 12263e48..09cde15e 100644 --- a/src/api2/admin/datastore.rs +++ b/src/api2/admin/datastore.rs @@ -1344,7 +1344,7 @@ fn catalog( if !components.is_empty() && components[0] == b'/' { components.remove(0); } - for component in components.split(|c| *c == '/' as u8) { + for component in components.split(|c| *c == b'/') { if let Some(entry) = catalog_reader.lookup(¤t, component)? { current = entry; } else { @@ -1357,7 +1357,7 @@ fn catalog( for direntry in catalog_reader.read_dir(¤t)? { let mut components = components.clone(); - components.push('/' as u8); + components.push(b'/'); components.extend(&direntry.name); let path = base64::encode(components); let text = String::from_utf8_lossy(&direntry.name); @@ -1491,7 +1491,7 @@ fn pxar_file_download( components.remove(0); } - let mut split = components.splitn(2, |c| *c == '/' as u8); + let mut split = components.splitn(2, |c| *c == b'/'); let pxar_name = std::str::from_utf8(split.next().unwrap())?; let file_path = split.next().ok_or(format_err!("filepath looks strange '{}'", filepath))?; let (manifest, files) = read_backup_index(&datastore, &backup_dir)?; diff --git a/src/backup/chunk_store.rs b/src/backup/chunk_store.rs index 39635d7d..f782169d 100644 --- a/src/backup/chunk_store.rs +++ b/src/backup/chunk_store.rs @@ -44,7 +44,7 @@ fn digest_to_prefix(digest: &[u8]) -> PathBuf { buf.push(HEX_CHARS[(digest[0] as usize) &0xf]); buf.push(HEX_CHARS[(digest[1] as usize) >> 4]); buf.push(HEX_CHARS[(digest[1] as usize) & 0xf]); - buf.push('/' as u8); + buf.push(b'/'); let path = unsafe { String::from_utf8_unchecked(buf)}; @@ -226,7 +226,7 @@ impl ChunkStore { continue; } - let bad = bytes.ends_with(".bad".as_bytes()); + let bad = bytes.ends_with(b".bad"); return Some((Ok(entry), percentage, bad)); } Some(Err(err)) => { diff --git a/src/backup/datastore.rs b/src/backup/datastore.rs index b384d88a..be764836 100644 --- a/src/backup/datastore.rs +++ b/src/backup/datastore.rs @@ -390,7 +390,7 @@ impl DataStore { fn is_hidden(entry: &walkdir::DirEntry) -> bool { entry.file_name() .to_str() - .map(|s| s.starts_with(".")) + .map(|s| s.starts_with('.')) .unwrap_or(false) } let handle_entry_err = |err: walkdir::Error| { diff --git a/src/config/network.rs b/src/config/network.rs index d6790afe..39f41c7e 100644 --- a/src/config/network.rs +++ b/src/config/network.rs @@ -578,7 +578,7 @@ pub fn complete_port_list(arg: &str, _param: &HashMap) -> Vec info.message = Some(value.into()), "validdirectory" => { - if value.split(",").find(is_server_id) == None { + if value.split(',').find(is_server_id) == None { bail!("Server ID does not match"); } info.serverid = Some(server_id.to_owned());