blob: 0d298fa20a580d87eac5e3e3febe64b4f5ec9c27 (
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#![feature(lang_items)]
#[lang = "clone"]
trait Clone {
fn clone(&self) -> Self;
}
#[lang = "sized"]
trait Sized {}
struct Abound {
a: u32,
b: u32,
}
struct Be<T: Clone> {
a: T,
b: Abound,
}
impl<T: Clone> Clone for Be<T> {
fn clone(&self) -> Self {
return Be::<T> {
a: self.a.clone(),
b: self.b.clone(),
};
}
}
impl Clone for u32 {
fn clone(&self) -> Self {
*self
}
}
impl Clone for usize {
fn clone(&self) -> Self {
*self
}
}
impl Clone for Abound {
fn clone(&self) -> Self {
return Abound {
a: self.a.clone(),
b: self.b.clone(),
};
}
}
fn main() {
let b: Be<usize> = Be {
a: 1,
b: Abound { a: 0, b: 1 },
};
let _: Be<usize> = b.clone();
}
|