Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> If you call a function that moves its argument to its return value, that move definitely won't get elided if the function is not inlined.

Wow that's worse than I thought. This means that any pub function that does this pattern of taking ownership then giving it back should have at least #[inline] to enable inlining across crates, or maybe even #[inline(always)].

The difference to C to C++ is that in Rust, such pattern is sometimes necessary to work around the borrow checker.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: