Puzzle 7: Explanation
Let’s learn how type conversion and structs work in Rust.
We'll cover the following...
We'll cover the following...
Test it out
Hit “Run” to see the code’s output.
Explanation
The surprise here is that the Into trait wasn’t implemented, yet the program could still use the into() function with the Radians type.
When we define the From trait, Rust automatically implements the reciprocal Into trait for us. This is very convenient and surprising, given Rust’s general insistence on the behavior being defined explicitly.
Prior to Rust version 1.4.1, this automatic implementation was only performed for types accessible from the crate ...