Skip to content

Commit 097c6ff

Browse files
authored
remove hyphen from chip string (esp-rs#183)
1 parent e055466 commit 097c6ff

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

espflash/src/chip/mod.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,16 @@ impl FromStr for Chip {
141141
type Err = Error;
142142

143143
fn from_str(s: &str) -> Result<Self, Self::Err> {
144-
match s.to_ascii_lowercase().as_str() {
144+
let s: String = s
145+
.chars()
146+
.filter(|&c| c != '-')
147+
.map(|c| c.to_ascii_lowercase())
148+
.collect();
149+
match s.as_str() {
145150
"esp32" => Ok(Chip::Esp32),
146-
"esp32-c3" => Ok(Chip::Esp32c3),
147-
"esp32-s2" => Ok(Chip::Esp32s2),
148-
"esp32-s3" => Ok(Chip::Esp32s3),
151+
"esp32c3" => Ok(Chip::Esp32c3),
152+
"esp32s2" => Ok(Chip::Esp32s2),
153+
"esp32s3" => Ok(Chip::Esp32s3),
149154
"esp8266" => Ok(Chip::Esp8266),
150155
_ => Err(Error::UnrecognizedChipName),
151156
}

0 commit comments

Comments
 (0)