Skip to content

simple-linked-list: fix hints.md #415

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

Merged
Merged
Show file tree
Hide file tree
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
5 changes: 2 additions & 3 deletions exercises/simple-linked-list/.meta/hints.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct Node<T> {
```
`data` contains the stored data, and `next` points to the following node (if available) or None.

### Why Option<__Box__<Node<T>>> and not just Option<Node<T>>?
### Why `Option<Box<Node<T>>>` and not just `Option<Node<T>>`?
Try it on your own. You will get the following error.

```
Expand All @@ -27,8 +27,7 @@ Try it on your own. You will get the following error.
| next: Option<Node<T>>,
| --------------------- recursive without indirection
```

The problem is that at compile time the size of next must be known.
Since `next` is recursive ("a node has a node has a node..."), the compiler does not know how much memory is to be allocated.
In contrast, [Box](https://doc.rust-lang.org/std/boxed/) is a heap pointer with a defined size.

6 changes: 3 additions & 3 deletions exercises/simple-linked-list/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct Node<T> {
```
`data` contains the stored data, and `next` points to the following node (if available) or None.

### Why Option<__Box__<Node<T>>> and not just Option<Node<T>>?
### Why `Option<Box<Node<T>>>` and not just `Option<Node<T>>`?
Try it on your own. You will get the following error.

```
Expand All @@ -50,11 +50,11 @@ Try it on your own. You will get the following error.
| next: Option<Node<T>>,
| --------------------- recursive without indirection
```

The problem is that at compile time the size of next must be known.
Since `next` is recursive ("a node has a node has a node..."), the compiler does not know how much memory is to be allocated.
In contrast, [Box](https://doc.rust-lang.org/std/boxed/) is a heap pointer with a defined size.


## Rust Installation

Expand Down