-
- generic functions with a trait bound use ‘monomorphization’ (mono: one, morph: form), so they are statically dispatched.
- This shows off the additional feature of
where
clauses: they allow bounds on the left-hand side not only of type parametersT
, but also of types
-
-
-
self
if it’s a value on the stack,&self
if it’s a reference, and&mut self
if it’s a mutable reference. - Rust doesn’t have method overloading, named arguments, or variable arguments.
-
-
- When we move
v
tov2
, Rust actually does a bitwise copy of the vector objectv
into the stack allocation represented byv2
. This shallow copy does not create a copy of the heap allocation containing the actual data. Which means that there would be two pointers to the contents of the vector both pointing to the same memory allocation on the heap.
-
-
Zero-Overhead Metaprogramming: Reflection and Metaobject Protocols Fast and without Compromises