Skip to content

Commit 13dfa1c

Browse files
committed
Simplify Partition constructor
The partition type can be inferred from the SubType enum, so no need to pass both.
1 parent 77ed92f commit 13dfa1c

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

espflash/src/partition_table.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ impl PartitionTable {
7777
PartitionTable {
7878
partitions: vec![Partition::new(
7979
String::from("factory"),
80-
Type::App,
8180
SubType::App(AppType::Factory),
8281
app_offset,
8382
app_size,
@@ -127,17 +126,13 @@ struct Partition {
127126
}
128127

129128
impl Partition {
130-
pub fn new(
131-
name: String,
132-
ty: Type,
133-
sub_type: SubType,
134-
offset: u32,
135-
size: u32,
136-
flags: u32,
137-
) -> Self {
129+
pub fn new(name: String, sub_type: SubType, offset: u32, size: u32, flags: u32) -> Self {
138130
Partition {
139131
name,
140-
ty,
132+
ty: match sub_type {
133+
SubType::App(_) => Type::App,
134+
SubType::Data(_) => Type::Data,
135+
},
141136
sub_type,
142137
offset,
143138
size,

0 commit comments

Comments
 (0)