12395 shaares
295 private links
295 private links
- giving every integer a shared helper method: define a trait with two required methods and one default method,
- Making class AnimatedServo still count as a Servo: require a trait in another trait
- adding a method to a type you don't own: implement a new trait for the primitive type
- giving a tiny Enum a full set of standard behaviors: the standard traits already exist and
derive - making a wrapper feel like the thing inside it: the wrapper can implement the thing and implement
DerefandDerefMut - adding union to any collection of range sets: mock a wrapper around a BTreeSet for example
- treating fifteen integer-link types the same way: to avoid writing the same method bodies 15 times, write a
macro_rules - Giving Only OutputArray<8> (8 bits) a Byte-Oriented Method: implement a general methods in the general impl block. It's named Constraint-Gated Methods.
- How would you make some methods available only when the method’s type parameter has the required capabilities? Use
serdeandpostcardwith aHashMapstanding in for flash memory.