Traits Deep Dive, Part 3

Sponsored by Parity Technologies! Parity is hiring Rust developers so if you're interested, you should check out their job listings!

You can see all of the pieces of the final example described in the show here (and the module has the required definitions for Point ).

let points = vec ! [ Point { x : 1.0 , y : 2.0 }, Point { x : 12.0 , y : 4.3 }, Point { x : - 5.4 , y : 18.7 }, ]; let origin = Point :: default (); let distances_inline : Vec < f32 > = points . iter () . map ( | point | { let change = point - & origin ; ( change . x . powi ( 2 ) + change . y . powi ( 2 )). sqrt () }) . collect (); let distances_impl : Vec < f32 > = points . iter (). map ( distance_from_impl ( & origin )). collect ();

(Thanks to the couple people donating who opted out of the reward tier, as well. You know who you are!)