Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 58ae1e7

Browse files
committedApr 17, 2014
Remove rule that is confusing
The original text stated that one should only return a unique or managed pointer if you were given one in the first place. This makes it sound as if the function *should* return a unique pointer if it were given a unique pointer. The rest of the section goes on to describe why this is bad, and the example of bad code does exactly what the rule just said to do. I reworded the original rule into a reference to the more concise rule mentioned at the bottom of the section, which helps add emphasis (a la 'it bears repeating').
1 parent ff0b0d5 commit 58ae1e7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed
 

‎src/doc/guide-pointers.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,9 @@ great detail, so if you want the full details, check that out.
430430
# Returning Pointers
431431

432432
We've talked a lot about functions that accept various kinds of pointers, but
433-
what about returning them? Here's the rule of thumb: only return a unique or
434-
managed pointer if you were given one in the first place.
433+
what about returning them? In general, it is better to let the caller decide
434+
how to use a function's output, instead of assuming a certain type of pointer
435+
is best.
435436

436437
What does that mean? Don't do this:
437438

5 commit comments

Comments
 (5)

bors commented on Apr 18, 2014

@bors
Collaborator

saw approval from cmr
at brandonw@58ae1e7

bors commented on Apr 18, 2014

@bors
Collaborator

merging brandonw/rust/patch-1 = 58ae1e7 into auto

bors commented on Apr 18, 2014

@bors
Collaborator

brandonw/rust/patch-1 = 58ae1e7 merged ok, testing candidate = ce2bab6

bors commented on Apr 18, 2014

@bors
Collaborator

fast-forwarding master to auto = ce2bab6

Please sign in to comment.