I have heard that there is a general sentiment that rust doesn't need or shouldn't have variadic functions because the builder pattern is so good. While I must admit that the builder pattern is very good, I still think that there are some use cases for variadic functions.
fn sum_all(start: usize, items: ...usize) -> usize;
use of functions:
let rest = [4, 6, 9]; sum_all(0, 1, 2, rest...) // == 21
A variadic function can be called with 0 or more arguments. The type is some type that implements
Iterator<item = T> for a declaration
A combination of individual and slice arguments are allowed. They will be iterated over in left to right order for each item. Effectively like
Such functions would be allowed in traits but would not have to be specified as a type parameter.
- Do nothing, we can currently specify something very close to this in another way: ie the builder pattern.
- Do not allow the joining of both individual items and other types of iterators. This is a smaller feature but I think it doesn't have enough weight behind it to be worth the effort.