blob: e14b9f379d62aafe343c465115d0995207960259 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
//@ known-bug: rust-lang/rust#129214
//@ compile-flags: -Zvalidate-mir -Copt-level=3 --crate-type=lib
trait to_str {}
trait map<T> {
fn map<U, F>(&self, f: F) -> Vec<U>
where
F: FnMut(&Box<usize>) -> U;
}
impl<T> map<T> for Vec<T> {
fn map<U, F>(&self, mut f: F) -> Vec<U>
where
F: FnMut(&T) -> U,
{
let mut r = Vec::new();
for i in self {
r.push(f(i));
}
r
}
}
fn foo<U, T: map<U>>(x: T) -> Vec<String> {
x.map(|_e| "hi".to_string())
}
pub fn main() {
assert_eq!(foo(vec![1]), ["hi".to_string()]);
}
|