Skip to content

Commit e91418d

Browse files
Copilotsjoerdsimons
andcommitted
Fix clippy and fmt errors for Rust 1.85
Co-authored-by: sjoerdsimons <[email protected]>
1 parent 9051b86 commit e91418d

File tree

5 files changed

+21
-8
lines changed

5 files changed

+21
-8
lines changed

bmap-parser/src/bmap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl Bmap {
9696
}
9797

9898
/// Iterator over the block map
99-
pub fn block_map(&self) -> impl ExactSizeIterator + Iterator<Item = &BlockRange> {
99+
pub fn block_map(&self) -> impl ExactSizeIterator<Item = &BlockRange> {
100100
self.blockmap.iter()
101101
}
102102

bmap-parser/src/bmap/xml.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,20 @@ struct Bmap {
5151
block_size: u64,
5252
#[serde(rename = "BlocksCount", deserialize_with = "deserialize_trimmed_u64")]
5353
blocks_count: u64,
54-
#[serde(rename = "MappedBlocksCount", deserialize_with = "deserialize_trimmed_u64")]
54+
#[serde(
55+
rename = "MappedBlocksCount",
56+
deserialize_with = "deserialize_trimmed_u64"
57+
)]
5558
mapped_blocks_count: u64,
56-
#[serde(rename = "ChecksumType", deserialize_with = "deserialize_trimmed_string")]
59+
#[serde(
60+
rename = "ChecksumType",
61+
deserialize_with = "deserialize_trimmed_string"
62+
)]
5763
checksum_type: String,
58-
#[serde(rename = "BmapFileChecksum", deserialize_with = "deserialize_trimmed_string")]
64+
#[serde(
65+
rename = "BmapFileChecksum",
66+
deserialize_with = "deserialize_trimmed_string"
67+
)]
5968
bmap_file_checksum: String,
6069
#[serde(rename = "BlockMap")]
6170
block_map: BlockMap,
@@ -101,7 +110,7 @@ fn str_to_digest(s: String, digest: &mut [u8]) -> Result<(), XmlError> {
101110
Some(v) => v,
102111
None => return Err(XmlError::InvalidChecksum(s)),
103112
};
104-
digest[i] = hi << 4 | lo;
113+
digest[i] = (hi << 4) | lo;
105114
}
106115

107116
Ok(())

bmap-parser/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ where
8585
left -= r;
8686
}
8787
let digest = hasher.finalize_reset();
88-
if range.checksum().as_slice() != digest.as_slice() {
88+
if range.checksum().as_slice() != &digest[..] {
8989
return Err(CopyError::ChecksumError);
9090
}
9191

@@ -139,7 +139,7 @@ where
139139
left -= r;
140140
}
141141
let digest = hasher.finalize_reset();
142-
if range.checksum().as_slice() != digest.as_slice() {
142+
if range.checksum().as_slice() != &digest[..] {
143143
return Err(CopyError::ChecksumError);
144144
}
145145

bmap-parser/tests/parse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fn parse() {
1818
assert_eq!((block + 1) * 4096, range.length());
1919

2020
let digest = Sha256::digest(format!("{}", block).as_bytes());
21-
assert_eq!(digest.as_slice(), range.checksum().as_slice());
21+
assert_eq!(&digest[..], range.checksum().as_slice());
2222

2323
block = if block == 0 { 8 } else { block * 4 };
2424
}

bmap-rs/src/main.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ fn copy_local_input(source: PathBuf, destination: PathBuf) -> Result<()> {
206206
let output = std::fs::OpenOptions::new()
207207
.write(true)
208208
.create(true)
209+
.truncate(true)
209210
.open(destination)?;
210211

211212
setup_output(&output, &bmap, output.metadata()?)?;
@@ -231,6 +232,7 @@ async fn copy_remote_input(source: Url, destination: PathBuf) -> Result<()> {
231232
let mut output = tokio::fs::OpenOptions::new()
232233
.write(true)
233234
.create(true)
235+
.truncate(true)
234236
.open(destination)
235237
.await?;
236238

@@ -263,6 +265,7 @@ fn copy_local_input_nobmap(source: PathBuf, destination: PathBuf) -> Result<()>
263265
let output = std::fs::OpenOptions::new()
264266
.write(true)
265267
.create(true)
268+
.truncate(true)
266269
.open(destination)?;
267270

268271
let mut input = setup_local_input(&source)?;
@@ -281,6 +284,7 @@ async fn copy_remote_input_nobmap(source: Url, destination: PathBuf) -> Result<(
281284
let mut output = tokio::fs::OpenOptions::new()
282285
.write(true)
283286
.create(true)
287+
.truncate(true)
284288
.open(destination)
285289
.await?;
286290

0 commit comments

Comments
 (0)