October 2018
Beginner
180 pages
4h 48m
English
Forward, Turn, and Stop are still three different data types. There's no data type that represents Forward, Turn, Stop, and though we could create one using an enumeration, there's another way. There is a data type that represents a borrow of any data type that has the PrintableDirection trait. It's written as &dyn PrintableDirection and is called a trait object reference.
The dyn keyword is short for dynamic dispatch, and it means that what looks ...
Read now
Unlock full access