I have a big object that I need boxed in another object but I don't necessarily need it all the time. So I want to use an if statement to get the optional boxed TempStructure but i'm not exactly sure how I can destructure and dereference at the same time.
Example:
pub struct TempStructure {
lots_of_data: [u64; 64],
}
pub struct Structure {
pending_removal: Option<Box<(TempStructure, bool)>>,
}
impl Structure {
pub fn do_somthing(&mut self) {
// How do I destructure the Option and dereference the Box to get TempStructure?
if let Some((temp_structure, some_boolean)) = self.pending_removal.take() {
// Do something with temp_structure and some_boolean
}
}
}
When I do this ^^^ I get an expected struct `std::boxed::Box`, found tuple
error.