[thin_shrink] fix some clippy warnings

This commit is contained in:
Joe Thornber 2020-06-26 08:31:02 +01:00
parent 7df56a5a04
commit d8a0805753
3 changed files with 11 additions and 11 deletions

View File

@ -43,7 +43,7 @@ where
Ok(()) Ok(())
} }
pub fn copy(path: &str, regions: &Vec<Region>) -> Result<()> { pub fn copy(path: &str, regions: &[Region]) -> Result<()> {
let mut input = OpenOptions::new() let mut input = OpenOptions::new()
.read(true) .read(true)
.write(true) .write(true)

View File

@ -1,5 +1,5 @@
use anyhow::Result; use anyhow::Result;
use fixedbitset::{FixedBitSet}; use fixedbitset::FixedBitSet;
use std::fs::OpenOptions; use std::fs::OpenOptions;
use std::io::Write; use std::io::Write;
use std::os::unix::fs::OpenOptionsExt; use std::os::unix::fs::OpenOptionsExt;
@ -163,7 +163,7 @@ fn bits_to_ranges(bits: &FixedBitSet) -> Vec<BlockRange> {
// Splits the ranges into those below threshold, and those equal or // Splits the ranges into those below threshold, and those equal or
// above threshold below threshold, and those equal or above threshold // above threshold below threshold, and those equal or above threshold
fn ranges_split(ranges: &Vec<BlockRange>, threshold: u64) -> (Vec<BlockRange>, Vec<BlockRange>) { fn ranges_split(ranges: &[BlockRange], threshold: u64) -> (Vec<BlockRange>, Vec<BlockRange>) {
use std::ops::Range; use std::ops::Range;
let mut below = Vec::new(); let mut below = Vec::new();
@ -181,7 +181,7 @@ fn ranges_split(ranges: &Vec<BlockRange>, threshold: u64) -> (Vec<BlockRange>, V
(below, above) (below, above)
} }
fn negate_ranges(ranges: &Vec<BlockRange>) -> Vec<BlockRange> { fn negate_ranges(ranges: &[BlockRange]) -> Vec<BlockRange> {
use std::ops::Range; use std::ops::Range;
let mut result = Vec::new(); let mut result = Vec::new();
@ -206,8 +206,8 @@ fn range_len(r: &BlockRange) -> u64 {
r.end - r.start r.end - r.start
} }
fn ranges_total(rs: &Vec<BlockRange>) -> u64 { fn ranges_total(rs: &[BlockRange]) -> u64 {
rs.into_iter().fold(0, |sum, r| sum + range_len(r)) rs.iter().fold(0, |sum, r| sum + range_len(r))
} }
// Assumes there is enough space to remap. // Assumes there is enough space to remap.
@ -261,8 +261,8 @@ fn overlaps(r1: &BlockRange, r2: &BlockRange, index: usize) -> Option<usize> {
} }
// Finds the index of the first entry that overlaps r. // Finds the index of the first entry that overlaps r.
fn find_first(r: &BlockRange, remaps: &Vec<(BlockRange, BlockRange)>) -> Option<usize> { fn find_first(r: &BlockRange, remaps: &[(BlockRange, BlockRange)]) -> Option<usize> {
if remaps.len() == 0 { if remaps.is_empty() {
return None; return None;
} }
@ -292,7 +292,7 @@ fn is_empty(r: &BlockRange) -> bool {
} }
// remaps must be in sorted order by from.start. // remaps must be in sorted order by from.start.
fn remap(r: &BlockRange, remaps: &Vec<(BlockRange, BlockRange)>) -> Vec<BlockRange> { fn remap(r: &BlockRange, remaps: &[(BlockRange, BlockRange)]) -> Vec<BlockRange> {
let mut remap = Vec::new(); let mut remap = Vec::new();
let mut r = r.start..r.end; let mut r = r.start..r.end;
@ -408,7 +408,7 @@ mod tests {
} }
} }
fn build_copy_regions(remaps: &Vec<(BlockRange, BlockRange)>, block_size: u64) -> Vec<Region> { fn build_copy_regions(remaps: &[(BlockRange, BlockRange)], block_size: u64) -> Vec<Region> {
let mut rs = Vec::new(); let mut rs = Vec::new();
for (from, to) in remaps { for (from, to) in remaps {

View File

@ -66,7 +66,7 @@ fn mk_attr_<'a, T: Display>(n: T) -> Cow<'a, [u8]> {
Cow::Owned(str.into_bytes()) Cow::Owned(str.into_bytes())
} }
fn mk_attr<'a, T: Display>(key: &[u8], value: T) -> Attribute { fn mk_attr<T: Display>(key: &[u8], value: T) -> Attribute {
Attribute { Attribute {
key, key,
value: mk_attr_(value), value: mk_attr_(value),