I see some Rust code that looks like this:
#![feature(default_type_params)]
After a lot of Googling, I get nothing about it. What is this? When should I use it?
It is enabling feature called default type parameters, but you already know that, so let me show you an example:
#![feature(default_type_params)]
struct Foo<A=(int, char)> { // default type parameter here!
a: A
}
fn default_foo(x: Foo) {
let (_i, _c): (int, char) = x.a;
}
fn main() {
default_foo(Foo { a: (1, 'a') })
}
Without default type parameters, you would need to explicitly set parameters:
struct Foo<A> {
a: A
}
fn default_foo(x: Foo<(int, char>)) {
let (_i, _c): (int, char) = x.a;
}
fn main() {
default_foo(Foo { a: (1, 'a') })
}
Example stolen from here: https://github.com/rust-lang/rust/pull/11217