hoist_temporaries

Procedural macro to extend the lifetimes of temporary variables.

crates.io Documentation Build Status

Examples

See working examples for more examples.

```rust

[hoisttemporaries::hoisttemporaries]

fn main() { #[hoisttemporaries::hoist] let mut snack = "Cheese"; if true { // Without hoisttemporaries, 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"); } ```