It just occurred to me that one can even "hide" the error by defining a method with the same name as the field:
impl<M: Fn(usize, usize) -> usize> Foo<M> {
fn matrix(&self, i: usize, j: usize) -> usize {
(self.matrix)(i, j)
}
}
That is, fields and methods are in separate namespaces and the namespaces can overlap. When you write foo.matrix and use it as a value, then you're accessing the matrix field. When you write foo.matrix(), you're accessing the matrix method.
I suppose that's pretty consistent ![]()