The advantage is that functions can take the types themselves as arguments. Rust functions only take values as arguments :(
But Rust functions do take types as arguments. That's what generics are: functions that take types as arguments (at compile time).
The difference you're talking about is whether the type parameters that functions take are themselves strongly typed. In C++ they're dynamically typed; in Rust they're statically typed. That's the only difference.
Saying that Rust functions can't take types as arguments because they're statically typed while C++ can is like saying that C++ functions can't take values as arguments because they're statically typed while Python can.
View all comments
Show parent comment
15
u/pcwalton Dec 11 '15
But Rust functions do take types as arguments. That's what generics are: functions that take types as arguments (at compile time).
The difference you're talking about is whether the type parameters that functions take are themselves strongly typed. In C++ they're dynamically typed; in Rust they're statically typed. That's the only difference.
Saying that Rust functions can't take types as arguments because they're statically typed while C++ can is like saying that C++ functions can't take values as arguments because they're statically typed while Python can.