hoist_temporaries 0.2.1

Procedural macro to extend the lifetimes of temporary variables.
Documentation

hoist_temporaries

Procedural macro to extend the lifetimes of temporary variables.

crates.io Documentation Build Status

Examples

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");
}