you've heard of builder pattern, but... let's say you have
let x = Foo::new();
x.thing(foo);
x.thing(bar);
x.thing(zed);
actually for better effect let's say you have
let x = { let mut temp = HashMap::new();
temp.insert("foo", "bar");
temp.insert("baz", "zed");
temp };
now, hashmaps are clearly not builders; but what if they could be used as if they were? we'd like to propose the following syntax:
let x = HashMap::new()(.insert("foo", "bar"))(.insert("baz", "zed"));
as exact sugar for the following:
let x = {
let mut temp = {
let mut temp = HashMap::new();
temp.insert("foo", "bar");
temp
};
temp.insert("baz", "zed");
temp
};
this is actually pretty easy to parse as the token for this is really (.
and not some arbitrary thing. but anyway. thoughts? this would also provide ergonomics for using certain types of iterators (but we don't have a good example for that).