mirror of
https://github.com/rust-lang/book.git
synced 2026-05-17 21:21:55 -04:00
Remove an outdated example that says it won't compile but it does
Fixes #1656.
This commit is contained in:
committed by
Carol (Nichols || Goulding)
parent
f17df27fc1
commit
45fe0fc9af
@@ -70,9 +70,8 @@ creating `c`, we’re not allowed to because `a` has been moved.
|
||||
We could change the definition of `Cons` to hold references instead, but then
|
||||
we would have to specify lifetime parameters. By specifying lifetime
|
||||
parameters, we would be specifying that every element in the list will live at
|
||||
least as long as the entire list. The borrow checker wouldn’t let us compile
|
||||
`let a = Cons(10, &Nil);` for example, because the temporary `Nil` value would
|
||||
be dropped before `a` could take a reference to it.
|
||||
least as long as the entire list. This is the case for the elements and lists
|
||||
in Listing 15-17, but not in every scenario.
|
||||
|
||||
Instead, we’ll change our definition of `List` to use `Rc<T>` in place of
|
||||
`Box<T>`, as shown in Listing 15-18. Each `Cons` variant will now hold a value
|
||||
|
||||
Reference in New Issue
Block a user