Skip to content

Commit 20f2ba0

Browse files
committed
Merge #52
52: edit to #49 r=Emilgardis a=Emilgardis
2 parents 4a03b42 + a9a9d82 commit 20f2ba0

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/lib.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,17 @@ pub struct Peripheral {
178178
}
179179

180180
impl Peripheral {
181+
pub fn derive_from(&self, other: &Peripheral) -> Peripheral {
182+
let mut derived = self.clone();
183+
derived.group_name = derived.group_name.or(other.group_name.clone());
184+
derived.description = derived.description.or(other.description.clone());
185+
derived.registers = derived.registers.or(other.registers.clone());
186+
if derived.interrupt.is_empty() {
187+
derived.interrupt = other.interrupt.clone();
188+
}
189+
derived
190+
}
191+
181192
fn parse(tree: &Element) -> Peripheral {
182193
assert_eq!(tree.name, "peripheral");
183194

0 commit comments

Comments
 (0)