Macro code_spells::evanesco
source · macro_rules! evanesco { ($item:expr) => { ... }; }
Expand description
Alias for Box::leak
. The item is still there, it’s just invisible. Can be revealed with aparecium!
.
Examples
If the returned pointer is dropped this causes a memory leak. You forgot where you put it, and it’s invisible.
ⓘ
let a = Box::new(vec![5; 100]);
evanesco!(a);
println!("{a:?}");
let ostrich = Box::new(vec![5; 100]);
// What do you have there?
evanesco!(ostrich);
// A smoothie..?
Using Box::from_raw
is one way of getting the item back.
This crate allows that function to be cast with aparecium!.
let a: &mut Vec<i32> = evanesco!(Box::new(vec![5; 100]));
assert_eq!(unsafe { aparecium!(a) }, Box::new(vec![5; 100]));