rust/src/test/compile-fail/issue-2149.rs

16 lines
344 B
Rust
Raw Normal View History

trait vec_monad<A> {
fn bind<B>(f: fn(A) -> ~[B]);
}
2012-08-07 18:10:06 -07:00
impl<A> ~[A]: vec_monad<A> {
fn bind<B>(f: fn(A) -> ~[B]) {
let mut r = fail;
2012-06-30 16:19:07 -07:00
for self.each |elt| { r += f(elt); }
//~^ WARNING unreachable expression
//~^^ ERROR the type of this value must be known
}
}
fn main() {
["hi"].bind({|x| [x] });
}