&mut Option<Box<T>> vs Option<&mut Box<T>>

What is the fundamental difference between these two when trying to mutate the object on the heap that the box is pointing to? Like I want to modify a field on Struct T

&mut Option<Box<T>>


Option<&mut Box<T>>

I know I can convert &Option to Option<&> but what is the difference between them when thinking about the Box inside it???

If you have an &mut Option<Box<T>>, then you can write a None to destroy the value. You can't do that with Option<&mut Box<T>>.


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.