hoist_temporaries
Procedural macro to extend the lifetimes of temporary variables.
Examples
See working examples for more examples.
Procedural macro to extend the lifetimes of temporary variables.
See working examples for more examples.
#[hoist_temporaries::hoist_temporaries]
fn main() {
#[hoist_temporaries::hoist]
let mut snack = "Cheese";
if true {
// Without hoist_temporaries, this would error because the format!() returns a temporary which would otherwise be dropped because it has no owner.
snack = &format!("{}burger", snack);
}
assert_eq!(snack, "Cheeseburger");
}