Using a move function to modify a mut reference

Given type T that does not implement Default or Copy.

Given function f with the following signature:

fn f(x: T) -> T

Given mutable reference r of type &mut T.

Question: How do I replace the content of r with f(*r)?

1 Like