about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorJosh Triplett <josh@joshtriplett.org>2023-06-28 17:10:03 -0700
committerJosh Triplett <josh@joshtriplett.org>2023-06-28 17:10:03 -0700
commit025dd3aef08d3674be596caf2ce2f260d00871c0 (patch)
treefe2daaf0e98333e13f599d3a942113cd7d2a28a8 /src
parenteb76764ea412b36f670564f5d58c317cec8fa496 (diff)
downloadrust-025dd3aef08d3674be596caf2ce2f260d00871c0.tar.gz
rust-025dd3aef08d3674be596caf2ce2f260d00871c0.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/doc/style-guide/src/expressions.md3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/doc/style-guide/src/expressions.md b/src/doc/style-guide/src/expressions.md
index 8271b42da4c..f5e37b6c46f 100644
--- a/src/doc/style-guide/src/expressions.md
+++ b/src/doc/style-guide/src/expressions.md
@@ -288,7 +288,8 @@ and other assignment operators such as `+=` or `*=`).
 
 For comparison operators, because for `T op U`, `&T op &U` is also implemented:
 if you have `t: &T`, and `u: U`, prefer `*t op u` to `t op &u`. In general,
-within expressions, prefer dereferencing to taking references.
+within expressions, prefer dereferencing to taking references, unless necessary
+(e.g. to avoid an unnecessarily expensive operation).
 
 Use parentheses liberally, do not necessarily elide them due to precedence.
 Tools should not automatically insert or remove parentheses. Do not use spaces