Skip to content

Commit

Permalink
Merge #180
Browse files Browse the repository at this point in the history
180: get_peripheral r=adamgreig a=burrbull

Missed in #179 

Co-authored-by: Andrey Zgarbul <zgarbul.andrey@gmail.com>
  • Loading branch information
bors[bot] and burrbull authored Dec 8, 2021
2 parents 745dabf + 5bf142f commit 460cdbf
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions svd-rs/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,4 +225,14 @@ impl Device {
}
Ok(())
}

/// Get peripheral by name
pub fn get_peripheral(&self, name: &str) -> Option<&Peripheral> {
self.peripherals.iter().find(|f| f.name == name)
}

/// Get mutable peripheral by name
pub fn get_mut_peripheral(&mut self, name: &str) -> Option<&mut Peripheral> {
self.peripherals.iter_mut().find(|f| f.name == name)
}
}

0 comments on commit 460cdbf

Please sign in to comment.