Crates.io | hoist_temporaries |
lib.rs | hoist_temporaries |
version | 0.2.1 |
source | src |
created_at | 2020-08-02 14:40:33.474967 |
updated_at | 2020-08-03 00:03:57.560822 |
description | Procedural macro to extend the lifetimes of temporary variables. |
homepage | |
repository | https://github.com/illicitonion/hoist_temporaries |
max_upload_size | |
id | 272237 |
size | 15,186 |
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");
}