Skip to content

Commit 025dd3a

Browse files
committed
style-guide: Narrow guidance about references and dereferencing
The style guide advises "prefer dereferencing to taking references", but doesn't give guidance on when that "preference" should get overridden by other considerations. Give an example of when it's fine to ignore that advice.
1 parent eb76764 commit 025dd3a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/doc/style-guide/src/expressions.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,8 @@ and other assignment operators such as `+=` or `*=`).
288288

289289
For comparison operators, because for `T op U`, `&T op &U` is also implemented:
290290
if you have `t: &T`, and `u: U`, prefer `*t op u` to `t op &u`. In general,
291-
within expressions, prefer dereferencing to taking references.
291+
within expressions, prefer dereferencing to taking references, unless necessary
292+
(e.g. to avoid an unnecessarily expensive operation).
292293

293294
Use parentheses liberally, do not necessarily elide them due to precedence.
294295
Tools should not automatically insert or remove parentheses. Do not use spaces

0 commit comments

Comments
 (0)