@@ -895,66 +895,6 @@ The fold method can be useful in the count_collection_iterator function.
895
895
For a further challenge, consult the documentation for Iterator to find
896
896
a different method that could make your code more compact than using fold."""
897
897
898
- [[exercises ]]
899
- name = " box1"
900
- path = " exercises/standard_library_types/box1.rs"
901
- mode = " test"
902
- hint = """
903
- Step 1
904
- The compiler's message should help: since we cannot store the value of the actual type
905
- when working with recursive types, we need to store a reference (pointer) to its value.
906
- We should, therefore, place our `List` inside a `Box`. More details in the book here:
907
- https://doc.rust-lang.org/book/ch15-01-box.html#enabling-recursive-types-with-boxes
908
-
909
- Step 2
910
- Creating an empty list should be fairly straightforward (hint: peek at the assertions).
911
- For a non-empty list keep in mind that we want to use our Cons "list builder".
912
- Although the current list is one of integers (i32), feel free to change the definition
913
- and try other types!
914
- """
915
-
916
- [[exercises ]]
917
- name = " arc1"
918
- path = " exercises/standard_library_types/arc1.rs"
919
- mode = " compile"
920
- hint = """
921
- Make `shared_numbers` be an `Arc` from the numbers vector. Then, in order
922
- to avoid creating a copy of `numbers`, you'll need to create `child_numbers`
923
- inside the loop but still in the main thread.
924
-
925
- `child_numbers` should be a clone of the Arc of the numbers instead of a
926
- thread-local copy of the numbers.
927
-
928
- This is a simple exercise if you understand the underlying concepts, but if this
929
- is too much of a struggle, consider reading through all of Chapter 16 in the book:
930
- https://doc.rust-lang.org/stable/book/ch16-00-concurrency.html
931
- """
932
-
933
- [[exercises ]]
934
- name = " rc1"
935
- path = " exercises/standard_library_types/rc1.rs"
936
- mode = " compile"
937
- hint = """
938
- This is a straightforward exercise to use the Rc<T> type. Each Planet has
939
- ownership of the Sun, and uses Rc::clone() to increment the reference count of the Sun.
940
- After using drop() to move the Planets out of scope individually, the reference count goes down.
941
- In the end the sun only has one reference again, to itself. See more at:
942
- https://doc.rust-lang.org/book/ch15-04-rc.html
943
-
944
- * Unfortunately Pluto is no longer considered a planet :(
945
- """
946
-
947
- [[exercises ]]
948
- name = " cow1"
949
- path = " exercises/standard_library_types/cow1.rs"
950
- mode = " compile"
951
- hint = """
952
- Since the vector is already owned, the `Cow` type doesn't need to clone it.
953
-
954
- Checkout https://doc.rust-lang.org/std/borrow/enum.Cow.html for documentation
955
- on the `Cow` type.
956
- """
957
-
958
898
# THREADS
959
899
960
900
[[exercises ]]
@@ -1016,6 +956,68 @@ of the original sending end.
1016
956
See https://doc.rust-lang.org/book/ch16-02-message-passing.html for more info.
1017
957
"""
1018
958
959
+ # SMART POINTERS
960
+
961
+ [[exercises ]]
962
+ name = " box1"
963
+ path = " exercises/standard_library_types/box1.rs"
964
+ mode = " test"
965
+ hint = """
966
+ Step 1
967
+ The compiler's message should help: since we cannot store the value of the actual type
968
+ when working with recursive types, we need to store a reference (pointer) to its value.
969
+ We should, therefore, place our `List` inside a `Box`. More details in the book here:
970
+ https://doc.rust-lang.org/book/ch15-01-box.html#enabling-recursive-types-with-boxes
971
+
972
+ Step 2
973
+ Creating an empty list should be fairly straightforward (hint: peek at the assertions).
974
+ For a non-empty list keep in mind that we want to use our Cons "list builder".
975
+ Although the current list is one of integers (i32), feel free to change the definition
976
+ and try other types!
977
+ """
978
+
979
+ [[exercises ]]
980
+ name = " rc1"
981
+ path = " exercises/standard_library_types/rc1.rs"
982
+ mode = " compile"
983
+ hint = """
984
+ This is a straightforward exercise to use the Rc<T> type. Each Planet has
985
+ ownership of the Sun, and uses Rc::clone() to increment the reference count of the Sun.
986
+ After using drop() to move the Planets out of scope individually, the reference count goes down.
987
+ In the end the sun only has one reference again, to itself. See more at:
988
+ https://doc.rust-lang.org/book/ch15-04-rc.html
989
+
990
+ * Unfortunately Pluto is no longer considered a planet :(
991
+ """
992
+
993
+ [[exercises ]]
994
+ name = " arc1"
995
+ path = " exercises/standard_library_types/arc1.rs"
996
+ mode = " compile"
997
+ hint = """
998
+ Make `shared_numbers` be an `Arc` from the numbers vector. Then, in order
999
+ to avoid creating a copy of `numbers`, you'll need to create `child_numbers`
1000
+ inside the loop but still in the main thread.
1001
+
1002
+ `child_numbers` should be a clone of the Arc of the numbers instead of a
1003
+ thread-local copy of the numbers.
1004
+
1005
+ This is a simple exercise if you understand the underlying concepts, but if this
1006
+ is too much of a struggle, consider reading through all of Chapter 16 in the book:
1007
+ https://doc.rust-lang.org/stable/book/ch16-00-concurrency.html
1008
+ """
1009
+
1010
+ [[exercises ]]
1011
+ name = " cow1"
1012
+ path = " exercises/standard_library_types/cow1.rs"
1013
+ mode = " compile"
1014
+ hint = """
1015
+ Since the vector is already owned, the `Cow` type doesn't need to clone it.
1016
+
1017
+ Checkout https://doc.rust-lang.org/std/borrow/enum.Cow.html for documentation
1018
+ on the `Cow` type.
1019
+ """
1020
+
1019
1021
# MACROS
1020
1022
1021
1023
[[exercises ]]
0 commit comments