Method/function overloading is a technique to have duplicate method/function names but different parameters for each. Many statically typed languages, such as C# and Java, support this in order to provide many ways to call a method without having to come up with a new name each time (or use generics). Rust, however, does not support that for functions—with good reason (https://blog.rust-lang.org/2015/05/11/traits.html). Where Rust does support overloading is with macro patterns: you can create a macro and have multiple arms that only differ in their input parameters.
Macro overloading
How to do it...
Let's implement some overloaded macros in a few simple steps:
- Run cargo new macro-overloading --lib in Terminal...