Does anyone have a more elegant solution for this situation?

72 points Tearsofthekorok_ 29 comments

Basically, I store data in an option, then immediately need to use it, specifically a reference to its memory location
currently i do this:

self.option = Some(value);
let Some(value) = &self.option else { panic!("How did this happen") };
//use value

Im not experienced enough nor smart enough to think of a better way to do this with the exception of something like a Arc