Skip to content

Instantly share code, notes, and snippets.

@vadixidav
Created April 29, 2018 00:27
Show Gist options
  • Save vadixidav/a1d3e7e3e656a6aedecdab7f732ac5d8 to your computer and use it in GitHub Desktop.
Save vadixidav/a1d3e7e3e656a6aedecdab7f732ac5d8 to your computer and use it in GitHub Desktop.
error[E0119]: conflicting implementations of trait `neighborhood::GetNeighbors<'_, usize, neumann::Neighbors<&_>>` for type `SquareGrid<_>`:
--> src\neumann.rs:195:1
|
177 | / impl<'a, C, S> GetNeighbors<'a, usize, Neighbors<&'a C>> for SquareGrid<S>
178 | | where
179 | | S: Sim<Cell = C>,
180 | | {
... |
192 | | }
193 | | }
| |_- first implementation here
194 |
195 | / impl<C, S> GetNeighbors<'static, usize, Neighbors<C>> for SquareGrid<S>
196 | | where
197 | | S: Sim<Cell = C>,
198 | | C: Clone,
... |
202 | | }
203 | | }
| |_^ conflicting implementation for `SquareGrid<_>`
impl<'a, C, S> GetNeighbors<'a, usize, Neighbors<&'a C>> for SquareGrid<S>
where
S: Sim<Cell = C>,
{
fn get_neighbors(&'a self, ix: usize) -> Neighbors<&'a C> {
Neighbors {
up_left: self.get_cell(self.size() + ix - 1 - self.width),
up: self.get_cell(self.size() + ix - self.width),
up_right: self.get_cell(self.size() + ix + 1 - self.width),
left: self.get_cell(self.size() + ix - 1),
right: self.get_cell(self.size() + ix + 1),
down_left: self.get_cell(self.size() + ix - 1 + self.width),
down: self.get_cell(self.size() + ix + self.width),
down_right: self.get_cell(self.size() + ix + 1 + self.width),
}
}
}
impl<C, S> GetNeighbors<'static, usize, Neighbors<C>> for SquareGrid<S>
where
S: Sim<Cell = C>,
C: Clone,
{
fn get_neighbors(&self, ix: usize) -> Neighbors<C> {
<Self as GetNeighbors<usize, Neighbors<&C>>>::get_neighbors(self, ix).cloned()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment