> Yeah, that's always been a minor annoyance of mine too. I intuitively think that
a(b());
should be treated like
let tmp = b();
a(tmp);
That is b() would terminate and release its borrows before a is even considered and "tmp" would live until the end of the block.
I'm guessing that there must be a good reason why it isn't so however.
That's because lifetimes in Rust are currently tied to a lexical scope - a borrow of a variable is kept alive until the variable goes out of scope, even if it's never used after a certain point in the function.
That's because lifetimes in Rust are currently tied to a lexical scope - a borrow of a variable is kept alive until the variable goes out of scope, even if it's never used after a certain point in the function.
There's currently an open RFC that would allow the kind of nested calls described in the blog post: https://github.com/rust-lang/rfcs/pull/2025