implementation when it finds a call for each combination of different types used in the generic parameters.
This can produce a lot of code if the function body is big.
```rust
pub fn work_with_path<T:AsRef<Path>>(path: T) {
// Here the body is small, but imagine this method has 100+ lines.
println!("{}", path.as_ref().display());
}
```
For every call to `work_with_path` with a different type `T` a implementation is generated.
Instead, we can do this
```rust
pub fn work_with_path<T:AsRef<Path>>(path: T) {
#[inline(never)] // inline is needed in this case because the inner method is small in the example.
fn work_with_path(path: &Path) {
println!("{}", path.display())
}
let path = path.as_ref();
work_with_path(path);
}
```
And the big meaty function will only be generated once, while the code to turn the type T into a valid reference to a path will be whats generated multiple times, depending on the T. Which usually is a small part of the method.
[Godbolt URL](https://godbolt.org/z/aaerf1PPE) (using `inline(never)` on the outer functions to avoid inlining them in main)
The `std` does this in multiple places, like this [one](https://doc.rust-lang.org/src/std/path.rs.html#2405-2411) or this [one](https://doc.rust-lang.org/src/std/path.rs.html#2603-2630)