Module show_notes::e025
source · Expand description
Traits Deep Dive, Part 3
§Show Notes
Sponsored by Parity Technologies! Parity is hiring Rust developers so if you’re interested, you should check out their job listings!
§Links
- RFC #1733: Trait Aliases
- RFC #255: Object Safety
- Ch. 17 in the Second Edition of The Rust Programming Language
- Huon Wilson’s post
§Example
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();
// This is the version we start with. It works fine, but it's not elegant.
let distances_inline: Vec<f32> = points
.iter()
.map(|point| {
let change = point - &origin;
(change.x.powi(2) + change.y.powi(2)).sqrt()
})
.collect();
// This version is *much* cleaner!
let distances_impl: Vec<f32> = points.iter().map(distance_from_impl(&origin)).collect();
§Sponsors
- Aaron Turon
- Alexander Kryvomaz
- Alexander Payne
- Anthony Deschamps
- Anthony Scotti
- Antonin Carette
- Aleksey Pirogov
- Andreas Fischer
- Andrew Thompson
- Austin LeSure
- Behnam Esfahbod
- Benjamin Wasty
- Brent Vatne
- Brian Casiello
- Chap Lovejoy
- Charlie Egan
- Chris Jones
- Chris Palmer
- Coleman McFarland
- Damien Stanton
- Dan Abrams
- Daniel Collin
- Daniel Mason
- Daniel P. Clark
- David W. Allen
- David Hewson
- Derek Buckley
- Derek Morr
- Eugene Bulkin
- [Hans Fjällemark]
- Henri Sivonen
- Ian Jones
- Jakub “Limeth” Hlusička
- James Cooper
- Jerome Froelich
- John Rudnick
- Jon
- Jonathan Turner
- Joseph Hain
- Jupp Müller
- Justin Ossevoort
- Karl Hobley
- Keith Gray
- Kilian Rault
- Laurie Hedge
- Luca Schmid
- Luiz Irber
- Mark LeMoine
- Martin Heuschober
- Masashi Fujita
- Matt Rudder
- Matthew Brenner
- Matthias Ruszala
- Max Jacobson
- Messense Lv
- Micael Bergeron
- Nathan Sculli
- Nick Coish
- Nick Stevens
- Oluseyi Sonaiya
- Ovidiu Curcan
- Pascal Hertleif
- Patrick O’Doherty
- [Paul Naranja]
- Peter Tillemans
- Ralph Giles (“rillian”)
- Raj Venkalil
- Ramon Buckland
- Randy MacLeod
- Raph Levien
- reddraggone9
- Robert Chrzanowski
- Ryan Blecher
- Ryan Osial
- Sebastián Ramírez Magrí
- Shane Utt
- Simon G.
- Steve Jenson
- Steven Knight
- Steven Murawski
- Stuart Hinson
- Tim Brooks
- Tom Prince
- Ty Overby
- Tyler Harper
- Vesa Kaihlavirta
- Victor Kruger
- Will Greenberg
- William Roe
- Yaacov Finkelman
- Zachary Snyder
- Zaki
(Thanks to the couple people donating who opted out of the reward tier, as well. You know who you are!)
§Become a sponsor
§Contact
- New Rustacean:
- Twitter: @newrustacean
- Email: hello@newrustacean.com
- Chris Krycho
- GitHub: chriskrycho
- Twitter: @chriskrycho
Structs§
- e025: Traits Deep Dive, Part III