File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -86,9 +86,22 @@ mod foo {
8686This convention avoids stuttering (like ` io::IoError ` ). Library clients can
8787rename on import to avoid clashes.
8888
89- ### Getter/setter methods [ FIXME ]
89+ ### Getter/setter methods [ RFC 344 ]
9090
91- > ** [ FIXME] ** Need a naming and signature convention here.
91+ > The guidelines below were approved by [ RFC #344 ] ( https://github.com/rust-lang/rfcs/pull/344 ) .
92+
93+ Some data structures do not wish to provide direct access to their fields, but
94+ instead offer "getter" and "setter" methods for manipulating the field state
95+ (often providing checking or other functionality).
96+
97+ The convention for a field ` foo: T ` is:
98+
99+ * A method ` foo(&self) -> &T ` for getting the current value of the field.
100+ * A method ` set_foo(&self, val: T) ` for setting the field. (The ` val ` argument
101+ here may take ` &T ` or some other type, depending on the context.)
102+
103+ Note that this convention is about getters/setters on ordinary data types, * not*
104+ on [ builder objects] ( ../ownership/builders.html ) .
92105
93106### Escape hatches [ FIXME]
94107
You can’t perform that action at this time.
0 commit comments