Closed
Description
Given the following code: this
pub struct MyWrapper(u32);
fn main() {
let value = MyWrapper(123);
some_fn(value.0);
}
fn some_fn(wrapped: MyWrapper) {
drop(wrapped);
}
The current output is:
Compiling playground v0.0.1 (/playground)
error[[E0308]](https://doc.rust-lang.org/stable/error-index.html#E0308): mismatched types
--> src/main.rs:6:13
|
6 | some_fn(value.0);
| ^^^^^^^ expected struct `MyWrapper`, found `u32`
|
help: try wrapping the expression in `MyWrapper`
|
6 | some_fn(MyWrapper(value.0));
| ++++++++++ +
For more information about this error, try `rustc --explain E0308`.
error: could not compile `playground` due to previous error
Ideally the output should look like:
Compiling playground v0.0.1 (/playground)
error[[E0308]](https://doc.rust-lang.org/stable/error-index.html#E0308): mismatched types
--> src/main.rs:6:13
|
6 | some_fn(value.0);
| ^^^^^^^ expected struct `MyWrapper`, found `u32`
|
help: try using `value` directly
|
6 | some_fn(value);
| +++++
For more information about this error, try `rustc --explain E0308`.
error: could not compile `playground` due to previous error
Just encountered this as I was refactoring code to properly use my tuple struct instead of an raw integer identifier.