1
1
error[E0308]: mismatched types
2
- --> $DIR/copied-and-cloned.rs:7:26
2
+ --> $DIR/copied-and-cloned.rs:10:13
3
+ |
4
+ LL | lol.x = x.clone();
5
+ | ----- ^^^^^^^^^ expected `Option<String>`, found `Option<&String>`
6
+ | |
7
+ | expected due to the type of this binding
8
+ |
9
+ = note: expected enum `Option<String>`
10
+ found enum `Option<&String>`
11
+ help: use `Option::cloned` to clone the value inside the `Option`
12
+ |
13
+ LL | lol.x = x.clone().cloned();
14
+ | +++++++++
15
+
16
+ error[E0308]: mismatched types
17
+ --> $DIR/copied-and-cloned.rs:17:26
3
18
|
4
19
LL | expect::<Option<()>>(x);
5
20
| -------------------- ^ expected `Option<()>`, found `Option<&()>`
@@ -19,7 +34,7 @@ LL | expect::<Option<()>>(x.copied());
19
34
| +++++++++
20
35
21
36
error[E0308]: mismatched types
22
- --> $DIR/copied-and-cloned.rs:11 :30
37
+ --> $DIR/copied-and-cloned.rs:21 :30
23
38
|
24
39
LL | expect::<Result<(), ()>>(x);
25
40
| ------------------------ ^ expected `Result<(), ()>`, found `Result<&(), _>`
@@ -39,7 +54,7 @@ LL | expect::<Result<(), ()>>(x.copied());
39
54
| +++++++++
40
55
41
56
error[E0308]: mismatched types
42
- --> $DIR/copied-and-cloned.rs:16 :30
57
+ --> $DIR/copied-and-cloned.rs:26 :30
43
58
|
44
59
LL | expect::<Option<String>>(x);
45
60
| ------------------------ ^ expected `Option<String>`, found `Option<&String>`
@@ -59,7 +74,7 @@ LL | expect::<Option<String>>(x.cloned());
59
74
| +++++++++
60
75
61
76
error[E0308]: mismatched types
62
- --> $DIR/copied-and-cloned.rs:20 :34
77
+ --> $DIR/copied-and-cloned.rs:30 :34
63
78
|
64
79
LL | expect::<Result<String, ()>>(x);
65
80
| ---------------------------- ^ expected `Result<String, ()>`, found `Result<&String, _>`
@@ -79,20 +94,20 @@ LL | expect::<Result<String, ()>>(x.cloned());
79
94
| +++++++++
80
95
81
96
error[E0308]: mismatched types
82
- --> $DIR/copied-and-cloned.rs:27 :25
97
+ --> $DIR/copied-and-cloned.rs:37 :25
83
98
|
84
99
LL | println!("{}", x == y);
85
100
| ^ expected `Option<String>`, found `Option<&String>`
86
101
|
87
102
= note: expected enum `Option<String>`
88
103
found enum `Option<&String>`
89
- help: use `Option::as_ref ` to convert `Option<String>` to `Option<&String> `
104
+ help: use `Option::cloned ` to clone the value inside the `Option`
90
105
|
91
- LL | println!("{}", x.as_ref() == y);
92
- | +++++++++
106
+ LL | println!("{}", x == y.cloned() );
107
+ | +++++++++
93
108
94
109
error[E0308]: mismatched types
95
- --> $DIR/copied-and-cloned.rs:35 :25
110
+ --> $DIR/copied-and-cloned.rs:45 :25
96
111
|
97
112
LL | println!("{}", x == y);
98
113
| ^ expected `Option<()>`, found `Option<&mut ()>`
@@ -105,7 +120,7 @@ LL | println!("{}", x == y.copied());
105
120
| +++++++++
106
121
107
122
error[E0308]: mismatched types
108
- --> $DIR/copied-and-cloned.rs:42 :25
123
+ --> $DIR/copied-and-cloned.rs:52 :25
109
124
|
110
125
LL | println!("{}", x == y);
111
126
| ^ expected `Option<String>`, found `Option<&mut String>`
@@ -117,6 +132,6 @@ help: use `Option::cloned` to clone the value inside the `Option`
117
132
LL | println!("{}", x == y.cloned());
118
133
| +++++++++
119
134
120
- error: aborting due to 7 previous errors
135
+ error: aborting due to 8 previous errors
121
136
122
137
For more information about this error, try `rustc --explain E0308`.
0 commit comments