api-guidelines
api-guidelines copied to clipboard
Missing setter convention described in RFC344
In RFC344, setter is described as:
* A method `set_foo(&self, val: T)` for setting the field. (The `val` argument
here may take `&T` or some other type, depending on the context.)
This was once added in commit a29a8417baa2722a5a9c17e48f2ff16bf35d6eb6
However, the current guideline only describes C-GETTER and does not describe how the setter should be named. Given that there are many results when searching for set_ in the std, I assume this is still the naming convention of the setter. search results
Should we add a description, or is this not suggested, and some API should be adjusted?
I also wonder whether a setter can always be achieved by a mutable getter. That is, is xxx.set_foo(T) equals *xxx.foo_mut() = T?