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)?

https://crates.io/crates/take_mut

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.