You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm a rust noob, so please tell me if I'm misunderstanding anything here, but:
In the "Borrowed pointers" chapter, when you talk about automatic referencing, you give the following example and explain that pointer types are automatically converted to references:
fnfoo(x:&i32){ ...}fnbar(x:i32,y:Box<i32>){foo(&x);// foo(x); // Error - expected &i32, found i32foo(y);// Okfoo(&*y);// Also ok, and more explicit, but not good style}
However, when trying this, the foo(y) line produces the following error:
error[E0308]: mismatched types
--> src/main.rs:132:9
|
132 | foo(y); // Ok
| --- ^ expected `&i32`, found `Box<i32>`
| |
| arguments to this function are incorrect
|
= note: expected reference `&i32`
found struct `Box<i32>`
note: function defined here
--> src/main.rs:127:4
|
127 | fn foo(x: &i32) {}
| ^^^ -------
help: consider borrowing here
|
132 | foo(&y); // Ok
| +
For more information about this error, try `rustc --explain E0308`.
So is this statement and the example wrong?
The text was updated successfully, but these errors were encountered:
I'm a rust noob, so please tell me if I'm misunderstanding anything here, but:
In the "Borrowed pointers" chapter, when you talk about automatic referencing, you give the following example and explain that pointer types are automatically converted to references:
However, when trying this, the
foo(y)
line produces the following error:So is this statement and the example wrong?
The text was updated successfully, but these errors were encountered: