Hi,
I was just thinking about that again, and I wonder if that could be used
to create a pattern for initialization "literals" for collections.
Once we have "yield fn" there could be syntax that converts
initialization code into a generator that is passed to a function call:
let mut l = List::literal() {{
~"foo",
~"bar"
}};
/* -> */
let mut l = List::literal((yield || -> Iterator<(~str)> {
yield return ~"foo",
yield return ~"bar"
}})());
And as an extension to make hashmap syntax nicer:
let mut hm = HashMap::literal() {{
~"foo" => 1,
~"bar" => 2
}};
/* -> */
let mut hm = HashMap::literal((yield || -> Iterator<(~str, int)> {
yield return (~"foo", 1),
yield return (~"bar", 2)
}})());
Unfortunately it could not be HashMap::new() because we can't have
functions with different argument counts :(
Regards,
Armin
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev