[<<][rust][>>][..]
Thu Feb 5 01:46:26 EST 2015

flat_map

01:44 < doelie> hi, any idea why this gives a lifetime error:
01:44 < doelie> fn main() { for _ in (0u8..10).flat_map(|x| (0u8..10).map(|y| x+y)) {} }
01:44 < lfairy> since contributors disagree on that
01:44 < eddyb_> doelie: flat_map stores its result
01:45 < eddyb_> doelie: maybe move |y| x+y will work for the inner closure
01:45 < doelie> eddyb_: thanks for the pointer
01:46 < eddyb_> doelie: the result of calling the closure you gave to it, to be precise (which in this case,
                contains another closure, which borrows x by default)
                

have a look at flat_map implementation.



[Reply][About]
[<<][rust][>>][..]