grid: add add_mut()
This commit is contained in:
parent
6283ff37f9
commit
2cf8527c4f
Binary file not shown.
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 8.8 KiB |
@ -1,6 +1,6 @@
|
||||
<!-- AOC TILES BEGIN -->
|
||||
<h1 align="center">
|
||||
2024 - 31 ⭐ - Rust
|
||||
2024 - 32 ⭐ - Rust
|
||||
</h1>
|
||||
<a href="src/day1.rs">
|
||||
<img src=".aoc_tiles/tiles/2024/01.png" width="161px">
|
||||
|
@ -181,6 +181,12 @@ impl<T: Clone + Eq + PartialEq + Debug> Grid<T> {
|
||||
None => None,
|
||||
}
|
||||
}
|
||||
pub fn get_mut<C: AsCoord2d>(&mut self, c: &C) -> Option<&mut T> {
|
||||
match self.valid_pos(c) {
|
||||
Some(pos) => Some(self.data.get_mut(pos).unwrap()),
|
||||
None => None,
|
||||
}
|
||||
}
|
||||
pub fn set<C: AsCoord2d>(&mut self, c: &C, mut val: T) -> Option<T> {
|
||||
match self.valid_pos(c) {
|
||||
Some(pos) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user