Why does this borrow last for whole statement?

I’m kind of surprised at that. Parsing obviously happens left-to-right, but the borrowing happening like that seems like it could be improved. Probably I’m missing something.

I read another post here about “context” arguments and how it’s nice to put them first, so they line up, because there are often repeated. Eg:

stack.add(ctx, button);
stack.add(ctx, label);
stack.add(ctx, make_other_widget(ctx)); 

But this borrowing issue motivates the opposite order. I’ll probably just leave it as the first parameter and write the extra lines for the intermediate variables.

I also created a convenience function add_to on my generic widget type.

button.add_to(ctx, &stack);
make_other_widget(ctx).add_to(ctx, &stack);

But that doesn’t line up the visual noise either.