The assign ops (Like
*= and so on) require the receiver to be a place and this leads to awkwardness with composite types like matrices and views thereof.
In ndarray we can use a method like
.column_mut(0) to get a mutable view of the first column. Basically this is the multidimensional array version of making a mutable slice. Arrays and array views support arithmetic operations, so we'd like to be able to use the
What we want to write (this doesn't compile!)
values.column_mut(0) += 1.
What we have to write:
*&mut values.column_mut(0) += 1.;
Can we do something about the rules for assignment operators to solve this papercut?
Users are unlikely to even find the one-liner solution to this, and the other one with a separate variable is also a papercut-type problem.
On the wishlist would be that
A. we can define
+= so that it can be used on temporary views like this.
B. Further, even on temporary views that are not even mutable. We want to fully support
ArrayView<Cell<f64>, _> in arithmetic operations in the future - we definitely want to support
+= on shared views of Cell elements.