Fix clippy warnings and formatting

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
This commit is contained in:
Andrew Gunnerson
2024-02-03 18:36:20 -05:00
parent 82fc1336f7
commit 8d25e28ea3
2 changed files with 6 additions and 6 deletions
+2 -2
View File
@@ -807,12 +807,12 @@ mod tests {
let size = 2 * 253 * 4096;
let fec = Fec::new(size, 4096, 2).unwrap();
assert_eq!(fec.rounds_for_ranges(&[0..0]).unwrap(), HashSet::new(),);
assert_eq!(fec.rounds_for_ranges(&[0..0]).unwrap(), HashSet::new());
assert_eq!(
fec.rounds_for_ranges(&[0..size]).unwrap(),
HashSet::from([0, 1]),
);
assert_eq!(fec.rounds_for_ranges(&[0..1]).unwrap(), HashSet::from([0]),);
assert_eq!(fec.rounds_for_ranges(&[0..1]).unwrap(), HashSet::from([0]));
assert_eq!(
fec.rounds_for_ranges(&[4095..4096]).unwrap(),
HashSet::from([0]),
+4 -4
View File
@@ -326,7 +326,7 @@ impl<'a> HashTree<'a> {
cancel_signal: &AtomicBool,
) -> Result<(Vec<u8>, Vec<u8>)> {
let offsets = self.compute_level_offsets(image_size)?;
let hash_tree_size = offsets.get(0).map(|r| r.end).unwrap_or(0);
let hash_tree_size = offsets.first().map(|r| r.end).unwrap_or(0);
let mut hash_tree_data = vec![0u8; hash_tree_size];
let root_digest = self.calculate(
@@ -352,7 +352,7 @@ impl<'a> HashTree<'a> {
cancel_signal: &AtomicBool,
) -> Result<Vec<u8>> {
let offsets = self.compute_level_offsets(image_size)?;
let hash_tree_size = offsets.get(0).map(|r| r.end).unwrap_or(0);
let hash_tree_size = offsets.first().map(|r| r.end).unwrap_or(0);
if hash_tree_data.len() != hash_tree_size {
return Err(Error::InvalidHashTreeSize {
input: image_size,
@@ -381,7 +381,7 @@ impl<'a> HashTree<'a> {
cancel_signal: &AtomicBool,
) -> Result<()> {
let offsets = self.compute_level_offsets(image_size)?;
let hash_tree_size = offsets.get(0).map(|r| r.end).unwrap_or(0);
let hash_tree_size = offsets.first().map(|r| r.end).unwrap_or(0);
if hash_tree_data.len() != hash_tree_size {
return Err(Error::InvalidHashTreeSize {
input: image_size,
@@ -637,7 +637,7 @@ mod tests {
hash_tree.blocks_for_ranges(16384, &[0..16384]).unwrap(),
&[0..4],
);
assert_eq!(hash_tree.blocks_for_ranges(16384, &[0..0]).unwrap(), &[],);
assert_eq!(hash_tree.blocks_for_ranges(16384, &[0..0]).unwrap(), &[]);
assert_eq!(
hash_tree
.blocks_for_ranges(16384, &[12287..12289, 0..1, 5000..5001])