Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix heading levels in pointer guide #16108

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/doc/guide-pointers.md
Original file line number Diff line number Diff line change
Expand Up @@ -578,12 +578,12 @@ fn main() {

Notice we changed the signature of `add_one()` to request a mutable reference.

# Best practices
## Best practices

Boxes are appropriate to use in two situations: Recursive data structures,
and occasionally, when returning data.

## Recursive data structures
### Recursive data structures

Sometimes, you need a recursive data structure. The simplest is known as a
'cons list':
Expand Down Expand Up @@ -615,7 +615,7 @@ we don't know the size, and therefore, we need to heap allocate our list.
Working with recursive or other unknown-sized data structures is the primary
use-case for boxes.

## Returning data
### Returning data

This is important enough to have its own section entirely. The TL;DR is this:
you don't generally want to return pointers, even when you might in a language
Expand Down