Mutable equivalent of Option::as_ref?

Is there any equivalent of Option::as_ref to convert &mut Option<T> into Option<&mut T> ?

I found the solution : Option::as_mut

_ref() with _mut() is a very common naming pattern. Look for it whenever you need a mutable reference. (Or adding a _mut or Mut suffix if the immutable version doesn't have "ref" in its name.)

1 Like

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.