Closed
Description
I thought this code would provide one of the nice suggestions that @estebank implemented in #75931, but it doesn't. (By the way, making cache
a reference to Cache
will give an ICE because of #77218.)
pub struct Cache {
data: Vec<i32>,
}
pub fn list_data(cache: Cache, key: &usize) {
for reference in vec![1, 2, 3] {
if /*let*/ Some(reference) = cache.data.get(*key) {
unimplemented!()
}
}
}
Errors:
Compiling playground v0.0.1 (/playground)
error[E0308]: mismatched types
--> src/lib.rs:7:38
|
7 | if /*let*/ Some(reference) = cache.data.get(*key) {
| ^^^^^^^^^^^^^^^^^^^^ expected integer, found `&i32`
|
= note: expected enum `Option<{integer}>`
found enum `Option<&i32>`
error[E0308]: mismatched types
--> src/lib.rs:7:20
|
7 | if /*let*/ Some(reference) = cache.data.get(*key) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `()`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0308`.
error: could not compile `playground`
To learn more, run the command again with --verbose.