3 unstable releases
0.2.1 | Aug 3, 2020 |
---|---|
0.2.0 | Aug 2, 2020 |
0.1.0 | Aug 2, 2020 |
#66 in #temporary
16KB
274 lines
hoist_temporaries
Procedural macro to extend the lifetimes of temporary variables.
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");
}
Dependencies
~1.5MB
~35K SLoC