Conservative trait return

This feature enables you to directly return a trait from a function. This means that in stable Rust, you will need to write this if you want to return a type that implements a trait without specifying the type:

fn iterate_something() -> Box<Iterator<Item = u32>> {    unimplemented!()}

This means that, before returning the iterator, you will need to move all of its information to the heap (this is done easily, but is costly with Box::new()) and then return it. This should not be necessary, since Rust should be able to know what type you are returning at compile time and allocate stack accordingly, then only let you use the trait, since it's what you specified beforehand.

Well, this has already been implemented in nightly ...

Get Rust High Performance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.