Hi, Allen! In fact, it is possible to do it now without DST, using unboxed closures only:
#![feature(unboxed_closures, unboxed_closure_sugar)] fn make_adder(x: int) -> Box<|&: int| -> int> { box |&: y: int| x + y } fn main() { let f = make_adder(3); println!("{}", f.call((4i,))); } Test it here: http://is.gd/mCJ6Dh This code employs the idea that unboxed closure is just an instance of some anonymous struct implementing one of Fn* traits, so we can just return a boxed trait object representing the closure. The call syntax is ugly, however, but this should change in the nearest future (though explicit dereferencing, like (*f)(x), will likely be needed anyway). 2014-09-10 0:39 GMT+04:00 Allen Welkie <allen.wel...@gmail.com>: > In this stackoverflow question: > > http://stackoverflow.com/questions/21130272/return-a-closure-from-a-function > > Chris Morgan mentions the possibility of adding closures with owned > environments with the DST implementation. Is this being done with the > current DST effort? If not, are there plans to add it? > > _______________________________________________ > Rust-dev mailing list > Rust-dev@mozilla.org > https://mail.mozilla.org/listinfo/rust-dev > _______________________________________________ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev