What do you think about syntax like
struct FooParams {
a: i32,
b: Option<i32>
}
fn foo(params: FooParams) {
…
}
// Current syntax
foo(FooParams { a: 10, b: None });
// proposed equivalent (both should be accepted)
foo({ a: 10, b: None });
// or
// foo(_ { a: 10, b: None }); // but I dislike it
It would provide “keyword arguments” in Rust 1.0.0 without any breaking changes.
PS
To be clear, this syntax should work iff there is no ambiguity about selected struct, so
fn foo<T>(params: T) where … {
…
}
foo({});
would be illegal as this would need some kind of guessing/casting between types.
Reasons:
This is the same way what JavaScript is doing it (or at least it is similar). It is IMHO really worth consideration as I don’t see any reason for Rust to have “keyword arguments” as we have enough tools to make it happen without additional syntax.