1
0
mirror of https://github.com/rust-lang/rustlings.git synced 2025-11-29 22:47:43 +02:00

box1 solution

This commit is contained in:
mo8it
2024-06-28 21:24:35 +02:00
parent f53d458920
commit 61c7eaed62
3 changed files with 66 additions and 27 deletions

View File

@@ -969,21 +969,16 @@ a different method that could make your code more compact than using `fold`."""
name = "box1"
dir = "19_smart_pointers"
hint = """
Step 1:
The compiler's message should help: since we cannot store the value of the
The compiler's message should help: Since we cannot store the value of the
actual type when working with recursive types, we need to store a reference
(pointer) to its value.
We should, therefore, place our `List` inside a `Box`. More details in the book
here: https://doc.rust-lang.org/book/ch15-01-box.html#enabling-recursive-types-with-boxes
We should, therefore, place our `List` inside a `Box`. More details in The Book:
https://doc.rust-lang.org/book/ch15-01-box.html#enabling-recursive-types-with-boxes
Step 2:
Creating an empty list should be fairly straightforward (Hint: Read the tests).
Creating an empty list should be fairly straightforward (hint: peek at the
assertions).
For a non-empty list keep in mind that we want to use our `Cons` "list builder".
For a non-empty list, keep in mind that we want to use our `Cons` list builder.
Although the current list is one of integers (`i32`), feel free to change the
definition and try other types!"""