Of course, we can say that the argument will change:
pub fn gcd<T>(mut a: T, mut b: T) -> T where T: Copy + Zero + PartialOrd + Rem<Output=T> { while b > T::zero() { let t = b; b = a % b; a = t; } a }
Is [declaring a modified copy of the argument] idiomatic / efficient?
This should be good in terms of efficiency. The optimizer will see that they are the same and do not perform extraneous copying.
As for the idioms, I'm not sure. Initially, I started by not putting mut in the argument list of my function, since I felt that this was excessive implementation information. I am currently advancing and putting it there.
source share