summaryrefslogtreecommitdiffstats
path: root/tests/ui/generics/generic-derived-type.rs
blob: c643496fa7f62cba37f9cff34c7d5ab2f9cab947 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// run-pass
fn g<X>(x: X) -> X { return x; }

#[derive(Clone)]
struct Pair<T> {
    a: T,
    b: T
}

fn f<T:Clone>(t: T) -> Pair<T> {
    let x: Pair<T> = Pair {a: t.clone(), b: t};
    return g::<Pair<T>>(x);
}

pub fn main() {
    let b = f::<isize>(10);
    println!("{}" ,b.a);
    println!("{}", b.b);
    assert_eq!(b.a, 10);
    assert_eq!(b.b, 10);
}