Stream: general

Topic: Borrowing and automatic execution


Daniel Papp (Jun 18 2019 at 11:39, on Zulip):

So there is this example of borrowing -> https://doc.rust-lang.org/beta/rust-by-example/scope/borrow.html fn borrow_i32(borrowed_i32: &i32) is getting called with a &Box<i32> I guess the Borrow trait is responsible for turning the &Box<i32> into and &i32. If it is how does the compiler know that it has to use the method from this trait or from some other in case it's a different trait? I just have a hard time figuring out how these things work in Rust.

Jake Goulding (Jun 18 2019 at 13:56, on Zulip):

I guess the Borrow trait is responsible

It is not. What are Rust's exact auto-dereferencing rules? and Deref.

Jake Goulding (Jun 18 2019 at 13:58, on Zulip):

Also, procedural aside: there's no problem with asking these types of questions here, but it's not the primary place for them, either. That's why responses are so slow. Regular "using Rust" questions are more frequent in the Discord or user's forum (https://www.rust-lang.org/community). Zulip tends to be more heavily used by the people working on compiler and other "implementation details"

Jake Goulding (Jun 18 2019 at 13:59, on Zulip):

So if you want responses any quicker, those might be better places :-)

Daniel Papp (Jun 18 2019 at 14:44, on Zulip):

Ah ok, I keep that in mind. Also thanks for the link.

Last update: Nov 20 2019 at 13:45UTC