Closed
Description
rustc 1.0.0-nightly (3ef8ff1 2015-02-12 00:38:24 +0000)
binary: rustc
commit-hash: 3ef8ff1
commit-date: 2015-02-12 00:38:24 +0000
host: x86_64-apple-darwin
release: 1.0.0-nightly
src/util.rs:44:25: 44:30 error: mismatched types:
expected `&_`,
found `Self`
(expected &-ptr,
found Self) [E0308]
src/util.rs:44 let indexer = &(*self as &Index<usize, Output = <Self as Index<usize>>::Output>);
^~~~~
src/util.rs:44:25: 44:30 error: internal compiler error: expected appropriate reference type
src/util.rs:44 let indexer = &(*self as &Index<usize, Output = <Self as Index<usize>>::Output>);
^~~~~
note: the compiler unexpectedly panicked. this is a bug.
Having a hell of a time getting some code to typecheck, and apparently broke the compiler with one attempt. Here's the code:
pub trait Array2D: Index<usize> {
fn rows(&self) -> usize;
fn columns(&self) -> usize;
fn get<'a>(&'a self, y: usize, x: usize) -> Option<&'a <Self as Index<usize>>::Output> {
if y >= self.rows() || x >= self.columns() {
return None;
}
let i = y * self.columns() + x;
let indexer = &(*self as &Index<usize, Output = <Self as Index<usize>>::Output>);
Some(indexer.index(&i))
}
}