Skip to content

Commit 770b2f8

Browse files
committed
Fix some clippy warnings, documentation updates
1 parent 421a8dc commit 770b2f8

File tree

5 files changed

+30
-10
lines changed

5 files changed

+30
-10
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# espflash
22

3-
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/esp-rs/espflash/rust.yml?branch=main&logoColor=1C2C2E&style=flat-square)
3+
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/esp-rs/espflash/rust.yml?branch=main&labelColor=1C2C2E&logo=github&style=flat-square)
44
![Crates.io](https://img.shields.io/crates/l/espflash?labelColor=1C2C2E&style=flat-square)
55
[![Matrix](https://img.shields.io/matrix/esp-rs:matrix.org?label=join%20matrix&color=BEC5C9&labelColor=1C2C2E&logo=matrix&style=flat-square)](https://matrix.to/#/#esp-rs:matrix.org)
66

espflash/src/command.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Send commands to a target device
2+
13
use std::{io::Write, mem::size_of, time::Duration};
24

35
use bytemuck::{bytes_of, Pod, Zeroable};

espflash/src/targets/flash_target/esp32.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ impl FlashTarget for Esp32Target {
131131
let chunks = compressed.chunks(flash_write_size);
132132
let num_chunks = chunks.len();
133133

134-
progress.as_mut().map(|cb| cb.init(addr, num_chunks));
134+
if let Some(cb) = progress.as_mut() {
135+
cb.init(addr, num_chunks)
136+
}
135137

136138
// decode the chunks to see how much data the device will have to save
137139
let mut decoder = ZlibDecoder::new(Vec::new());
@@ -156,10 +158,14 @@ impl FlashTarget for Esp32Target {
156158
},
157159
)?;
158160

159-
progress.as_mut().map(|cb| cb.update(i + 1));
161+
if let Some(cb) = progress.as_mut() {
162+
cb.update(i + 1)
163+
}
160164
}
161165

162-
progress.as_mut().map(|cb| cb.finish());
166+
if let Some(cb) = progress.as_mut() {
167+
cb.finish()
168+
}
163169

164170
Ok(())
165171
}

espflash/src/targets/flash_target/esp8266.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ impl FlashTarget for Esp8266Target {
5757
let chunks = segment.data.chunks(FLASH_WRITE_SIZE);
5858
let num_chunks = chunks.len();
5959

60-
progress.as_mut().map(|cb| cb.init(addr, num_chunks));
60+
if let Some(cb) = progress.as_mut() {
61+
cb.init(addr, num_chunks)
62+
}
6163

6264
for (i, block) in chunks.enumerate() {
6365
connection.command(Command::FlashData {
@@ -67,10 +69,14 @@ impl FlashTarget for Esp8266Target {
6769
data: block,
6870
})?;
6971

70-
progress.as_mut().map(|cb| cb.update(i + 1));
72+
if let Some(cb) = progress.as_mut() {
73+
cb.update(i + 1)
74+
}
7175
}
7276

73-
progress.as_mut().map(|cb| cb.finish());
77+
if let Some(cb) = progress.as_mut() {
78+
cb.finish()
79+
}
7480

7581
Ok(())
7682
}

espflash/src/targets/flash_target/ram.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ impl FlashTarget for RamTarget {
6363
let chunks = segment.data.chunks(self.block_size);
6464
let num_chunks = chunks.len();
6565

66-
progress.as_mut().map(|cb| cb.init(addr, num_chunks));
66+
if let Some(cb) = progress.as_mut() {
67+
cb.init(addr, num_chunks)
68+
}
6769

6870
for (i, block) in chunks.enumerate() {
6971
connection.command(Command::MemData {
@@ -73,10 +75,14 @@ impl FlashTarget for RamTarget {
7375
data: block,
7476
})?;
7577

76-
progress.as_mut().map(|cb| cb.update(i + 1));
78+
if let Some(cb) = progress.as_mut() {
79+
cb.update(i + 1)
80+
}
7781
}
7882

79-
progress.as_mut().map(|cb| cb.finish());
83+
if let Some(cb) = progress.as_mut() {
84+
cb.finish()
85+
}
8086

8187
Ok(())
8288
}

0 commit comments

Comments
 (0)