From 2dac8e509bed07c30a98983cfb6b80f73a1582e9 Mon Sep 17 00:00:00 2001 From: mo8it Date: Tue, 23 Apr 2024 19:18:25 +0200 Subject: Refactor embedded files to add solutions --- solutions/05_vecs/vecs2.rs | 1 + 1 file changed, 1 insertion(+) create mode 100644 solutions/05_vecs/vecs2.rs (limited to 'solutions/05_vecs/vecs2.rs') diff --git a/solutions/05_vecs/vecs2.rs b/solutions/05_vecs/vecs2.rs new file mode 100644 index 0000000..70b786d --- /dev/null +++ b/solutions/05_vecs/vecs2.rs @@ -0,0 +1 @@ +// TODO -- cgit v1.2.3 From 177e2870c5272dacee662d3e9522bc57c5a134c0 Mon Sep 17 00:00:00 2001 From: mo8it Date: Thu, 25 Apr 2024 16:30:01 +0200 Subject: Edit comment --- solutions/00_intro/intro1.rs | 2 +- solutions/00_intro/intro2.rs | 2 +- solutions/01_variables/variables1.rs | 2 +- solutions/01_variables/variables2.rs | 2 +- solutions/01_variables/variables3.rs | 2 +- solutions/01_variables/variables4.rs | 2 +- solutions/01_variables/variables5.rs | 2 +- solutions/01_variables/variables6.rs | 2 +- solutions/02_functions/functions1.rs | 2 +- solutions/02_functions/functions2.rs | 2 +- solutions/02_functions/functions3.rs | 2 +- solutions/02_functions/functions4.rs | 2 +- solutions/02_functions/functions5.rs | 2 +- solutions/03_if/if1.rs | 2 +- solutions/03_if/if2.rs | 2 +- solutions/03_if/if3.rs | 2 +- solutions/04_primitive_types/primitive_types1.rs | 2 +- solutions/04_primitive_types/primitive_types2.rs | 2 +- solutions/04_primitive_types/primitive_types3.rs | 2 +- solutions/04_primitive_types/primitive_types4.rs | 2 +- solutions/04_primitive_types/primitive_types5.rs | 2 +- solutions/04_primitive_types/primitive_types6.rs | 2 +- solutions/05_vecs/vecs1.rs | 2 +- solutions/05_vecs/vecs2.rs | 2 +- solutions/06_move_semantics/move_semantics1.rs | 2 +- solutions/06_move_semantics/move_semantics2.rs | 2 +- solutions/06_move_semantics/move_semantics3.rs | 2 +- solutions/06_move_semantics/move_semantics4.rs | 2 +- solutions/06_move_semantics/move_semantics5.rs | 2 +- solutions/06_move_semantics/move_semantics6.rs | 2 +- solutions/07_structs/structs1.rs | 2 +- solutions/07_structs/structs2.rs | 2 +- solutions/07_structs/structs3.rs | 2 +- solutions/08_enums/enums1.rs | 2 +- solutions/08_enums/enums2.rs | 2 +- solutions/08_enums/enums3.rs | 2 +- solutions/09_strings/strings1.rs | 2 +- solutions/09_strings/strings2.rs | 2 +- solutions/09_strings/strings3.rs | 2 +- solutions/09_strings/strings4.rs | 2 +- solutions/10_modules/modules1.rs | 2 +- solutions/10_modules/modules2.rs | 2 +- solutions/10_modules/modules3.rs | 2 +- solutions/11_hashmaps/hashmaps1.rs | 2 +- solutions/11_hashmaps/hashmaps2.rs | 2 +- solutions/11_hashmaps/hashmaps3.rs | 2 +- solutions/12_options/options1.rs | 2 +- solutions/12_options/options2.rs | 2 +- solutions/12_options/options3.rs | 2 +- solutions/13_error_handling/errors1.rs | 2 +- solutions/13_error_handling/errors2.rs | 2 +- solutions/13_error_handling/errors3.rs | 2 +- solutions/13_error_handling/errors4.rs | 2 +- solutions/13_error_handling/errors5.rs | 2 +- solutions/13_error_handling/errors6.rs | 2 +- solutions/14_generics/generics1.rs | 2 +- solutions/14_generics/generics2.rs | 2 +- solutions/15_traits/traits1.rs | 2 +- solutions/15_traits/traits2.rs | 2 +- solutions/15_traits/traits3.rs | 2 +- solutions/15_traits/traits4.rs | 2 +- solutions/15_traits/traits5.rs | 2 +- solutions/16_lifetimes/lifetimes1.rs | 2 +- solutions/16_lifetimes/lifetimes2.rs | 2 +- solutions/16_lifetimes/lifetimes3.rs | 2 +- solutions/17_tests/tests1.rs | 2 +- solutions/17_tests/tests2.rs | 2 +- solutions/17_tests/tests3.rs | 2 +- solutions/17_tests/tests4.rs | 2 +- solutions/18_iterators/iterators1.rs | 2 +- solutions/18_iterators/iterators2.rs | 2 +- solutions/18_iterators/iterators3.rs | 2 +- solutions/18_iterators/iterators4.rs | 2 +- solutions/18_iterators/iterators5.rs | 2 +- solutions/19_smart_pointers/arc1.rs | 2 +- solutions/19_smart_pointers/box1.rs | 2 +- solutions/19_smart_pointers/cow1.rs | 2 +- solutions/19_smart_pointers/rc1.rs | 2 +- solutions/20_threads/threads1.rs | 2 +- solutions/20_threads/threads2.rs | 2 +- solutions/20_threads/threads3.rs | 2 +- solutions/21_macros/macros1.rs | 2 +- solutions/21_macros/macros2.rs | 2 +- solutions/21_macros/macros3.rs | 2 +- solutions/21_macros/macros4.rs | 2 +- solutions/22_clippy/clippy1.rs | 2 +- solutions/22_clippy/clippy2.rs | 2 +- solutions/22_clippy/clippy3.rs | 2 +- solutions/23_conversions/as_ref_mut.rs | 2 +- solutions/23_conversions/from_into.rs | 2 +- solutions/23_conversions/from_str.rs | 2 +- solutions/23_conversions/try_from_into.rs | 2 +- solutions/23_conversions/using_as.rs | 2 +- solutions/quizzes/quiz1.rs | 2 +- solutions/quizzes/quiz2.rs | 2 +- solutions/quizzes/quiz3.rs | 2 +- 96 files changed, 96 insertions(+), 96 deletions(-) (limited to 'solutions/05_vecs/vecs2.rs') diff --git a/solutions/00_intro/intro1.rs b/solutions/00_intro/intro1.rs index 70b786d..4e18198 100644 --- a/solutions/00_intro/intro1.rs +++ b/solutions/00_intro/intro1.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/00_intro/intro2.rs b/solutions/00_intro/intro2.rs index 70b786d..4e18198 100644 --- a/solutions/00_intro/intro2.rs +++ b/solutions/00_intro/intro2.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/01_variables/variables1.rs b/solutions/01_variables/variables1.rs index 70b786d..4e18198 100644 --- a/solutions/01_variables/variables1.rs +++ b/solutions/01_variables/variables1.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/01_variables/variables2.rs b/solutions/01_variables/variables2.rs index 70b786d..4e18198 100644 --- a/solutions/01_variables/variables2.rs +++ b/solutions/01_variables/variables2.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/01_variables/variables3.rs b/solutions/01_variables/variables3.rs index 70b786d..4e18198 100644 --- a/solutions/01_variables/variables3.rs +++ b/solutions/01_variables/variables3.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/01_variables/variables4.rs b/solutions/01_variables/variables4.rs index 70b786d..4e18198 100644 --- a/solutions/01_variables/variables4.rs +++ b/solutions/01_variables/variables4.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/01_variables/variables5.rs b/solutions/01_variables/variables5.rs index 70b786d..4e18198 100644 --- a/solutions/01_variables/variables5.rs +++ b/solutions/01_variables/variables5.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/01_variables/variables6.rs b/solutions/01_variables/variables6.rs index 70b786d..4e18198 100644 --- a/solutions/01_variables/variables6.rs +++ b/solutions/01_variables/variables6.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/02_functions/functions1.rs b/solutions/02_functions/functions1.rs index 70b786d..4e18198 100644 --- a/solutions/02_functions/functions1.rs +++ b/solutions/02_functions/functions1.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/02_functions/functions2.rs b/solutions/02_functions/functions2.rs index 70b786d..4e18198 100644 --- a/solutions/02_functions/functions2.rs +++ b/solutions/02_functions/functions2.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/02_functions/functions3.rs b/solutions/02_functions/functions3.rs index 70b786d..4e18198 100644 --- a/solutions/02_functions/functions3.rs +++ b/solutions/02_functions/functions3.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/02_functions/functions4.rs b/solutions/02_functions/functions4.rs index 70b786d..4e18198 100644 --- a/solutions/02_functions/functions4.rs +++ b/solutions/02_functions/functions4.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/02_functions/functions5.rs b/solutions/02_functions/functions5.rs index 70b786d..4e18198 100644 --- a/solutions/02_functions/functions5.rs +++ b/solutions/02_functions/functions5.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/03_if/if1.rs b/solutions/03_if/if1.rs index 70b786d..4e18198 100644 --- a/solutions/03_if/if1.rs +++ b/solutions/03_if/if1.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/03_if/if2.rs b/solutions/03_if/if2.rs index 70b786d..4e18198 100644 --- a/solutions/03_if/if2.rs +++ b/solutions/03_if/if2.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/03_if/if3.rs b/solutions/03_if/if3.rs index 70b786d..4e18198 100644 --- a/solutions/03_if/if3.rs +++ b/solutions/03_if/if3.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/04_primitive_types/primitive_types1.rs b/solutions/04_primitive_types/primitive_types1.rs index 70b786d..4e18198 100644 --- a/solutions/04_primitive_types/primitive_types1.rs +++ b/solutions/04_primitive_types/primitive_types1.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/04_primitive_types/primitive_types2.rs b/solutions/04_primitive_types/primitive_types2.rs index 70b786d..4e18198 100644 --- a/solutions/04_primitive_types/primitive_types2.rs +++ b/solutions/04_primitive_types/primitive_types2.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/04_primitive_types/primitive_types3.rs b/solutions/04_primitive_types/primitive_types3.rs index 70b786d..4e18198 100644 --- a/solutions/04_primitive_types/primitive_types3.rs +++ b/solutions/04_primitive_types/primitive_types3.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/04_primitive_types/primitive_types4.rs b/solutions/04_primitive_types/primitive_types4.rs index 70b786d..4e18198 100644 --- a/solutions/04_primitive_types/primitive_types4.rs +++ b/solutions/04_primitive_types/primitive_types4.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/04_primitive_types/primitive_types5.rs b/solutions/04_primitive_types/primitive_types5.rs index 70b786d..4e18198 100644 --- a/solutions/04_primitive_types/primitive_types5.rs +++ b/solutions/04_primitive_types/primitive_types5.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/04_primitive_types/primitive_types6.rs b/solutions/04_primitive_types/primitive_types6.rs index 70b786d..4e18198 100644 --- a/solutions/04_primitive_types/primitive_types6.rs +++ b/solutions/04_primitive_types/primitive_types6.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/05_vecs/vecs1.rs b/solutions/05_vecs/vecs1.rs index 70b786d..4e18198 100644 --- a/solutions/05_vecs/vecs1.rs +++ b/solutions/05_vecs/vecs1.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/05_vecs/vecs2.rs b/solutions/05_vecs/vecs2.rs index 70b786d..4e18198 100644 --- a/solutions/05_vecs/vecs2.rs +++ b/solutions/05_vecs/vecs2.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/06_move_semantics/move_semantics1.rs b/solutions/06_move_semantics/move_semantics1.rs index 70b786d..4e18198 100644 --- a/solutions/06_move_semantics/move_semantics1.rs +++ b/solutions/06_move_semantics/move_semantics1.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/06_move_semantics/move_semantics2.rs b/solutions/06_move_semantics/move_semantics2.rs index 70b786d..4e18198 100644 --- a/solutions/06_move_semantics/move_semantics2.rs +++ b/solutions/06_move_semantics/move_semantics2.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/06_move_semantics/move_semantics3.rs b/solutions/06_move_semantics/move_semantics3.rs index 70b786d..4e18198 100644 --- a/solutions/06_move_semantics/move_semantics3.rs +++ b/solutions/06_move_semantics/move_semantics3.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/06_move_semantics/move_semantics4.rs b/solutions/06_move_semantics/move_semantics4.rs index 70b786d..4e18198 100644 --- a/solutions/06_move_semantics/move_semantics4.rs +++ b/solutions/06_move_semantics/move_semantics4.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/06_move_semantics/move_semantics5.rs b/solutions/06_move_semantics/move_semantics5.rs index 70b786d..4e18198 100644 --- a/solutions/06_move_semantics/move_semantics5.rs +++ b/solutions/06_move_semantics/move_semantics5.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/06_move_semantics/move_semantics6.rs b/solutions/06_move_semantics/move_semantics6.rs index 70b786d..4e18198 100644 --- a/solutions/06_move_semantics/move_semantics6.rs +++ b/solutions/06_move_semantics/move_semantics6.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/07_structs/structs1.rs b/solutions/07_structs/structs1.rs index 70b786d..4e18198 100644 --- a/solutions/07_structs/structs1.rs +++ b/solutions/07_structs/structs1.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/07_structs/structs2.rs b/solutions/07_structs/structs2.rs index 70b786d..4e18198 100644 --- a/solutions/07_structs/structs2.rs +++ b/solutions/07_structs/structs2.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/07_structs/structs3.rs b/solutions/07_structs/structs3.rs index 70b786d..4e18198 100644 --- a/solutions/07_structs/structs3.rs +++ b/solutions/07_structs/structs3.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/08_enums/enums1.rs b/solutions/08_enums/enums1.rs index 70b786d..4e18198 100644 --- a/solutions/08_enums/enums1.rs +++ b/solutions/08_enums/enums1.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/08_enums/enums2.rs b/solutions/08_enums/enums2.rs index 70b786d..4e18198 100644 --- a/solutions/08_enums/enums2.rs +++ b/solutions/08_enums/enums2.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/08_enums/enums3.rs b/solutions/08_enums/enums3.rs index 70b786d..4e18198 100644 --- a/solutions/08_enums/enums3.rs +++ b/solutions/08_enums/enums3.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/09_strings/strings1.rs b/solutions/09_strings/strings1.rs index 70b786d..4e18198 100644 --- a/solutions/09_strings/strings1.rs +++ b/solutions/09_strings/strings1.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/09_strings/strings2.rs b/solutions/09_strings/strings2.rs index 70b786d..4e18198 100644 --- a/solutions/09_strings/strings2.rs +++ b/solutions/09_strings/strings2.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/09_strings/strings3.rs b/solutions/09_strings/strings3.rs index 70b786d..4e18198 100644 --- a/solutions/09_strings/strings3.rs +++ b/solutions/09_strings/strings3.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/09_strings/strings4.rs b/solutions/09_strings/strings4.rs index 70b786d..4e18198 100644 --- a/solutions/09_strings/strings4.rs +++ b/solutions/09_strings/strings4.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/10_modules/modules1.rs b/solutions/10_modules/modules1.rs index 70b786d..4e18198 100644 --- a/solutions/10_modules/modules1.rs +++ b/solutions/10_modules/modules1.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/10_modules/modules2.rs b/solutions/10_modules/modules2.rs index 70b786d..4e18198 100644 --- a/solutions/10_modules/modules2.rs +++ b/solutions/10_modules/modules2.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/10_modules/modules3.rs b/solutions/10_modules/modules3.rs index 70b786d..4e18198 100644 --- a/solutions/10_modules/modules3.rs +++ b/solutions/10_modules/modules3.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/11_hashmaps/hashmaps1.rs b/solutions/11_hashmaps/hashmaps1.rs index 70b786d..4e18198 100644 --- a/solutions/11_hashmaps/hashmaps1.rs +++ b/solutions/11_hashmaps/hashmaps1.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/11_hashmaps/hashmaps2.rs b/solutions/11_hashmaps/hashmaps2.rs index 70b786d..4e18198 100644 --- a/solutions/11_hashmaps/hashmaps2.rs +++ b/solutions/11_hashmaps/hashmaps2.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/11_hashmaps/hashmaps3.rs b/solutions/11_hashmaps/hashmaps3.rs index 70b786d..4e18198 100644 --- a/solutions/11_hashmaps/hashmaps3.rs +++ b/solutions/11_hashmaps/hashmaps3.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/12_options/options1.rs b/solutions/12_options/options1.rs index 70b786d..4e18198 100644 --- a/solutions/12_options/options1.rs +++ b/solutions/12_options/options1.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/12_options/options2.rs b/solutions/12_options/options2.rs index 70b786d..4e18198 100644 --- a/solutions/12_options/options2.rs +++ b/solutions/12_options/options2.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/12_options/options3.rs b/solutions/12_options/options3.rs index 70b786d..4e18198 100644 --- a/solutions/12_options/options3.rs +++ b/solutions/12_options/options3.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/13_error_handling/errors1.rs b/solutions/13_error_handling/errors1.rs index 70b786d..4e18198 100644 --- a/solutions/13_error_handling/errors1.rs +++ b/solutions/13_error_handling/errors1.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/13_error_handling/errors2.rs b/solutions/13_error_handling/errors2.rs index 70b786d..4e18198 100644 --- a/solutions/13_error_handling/errors2.rs +++ b/solutions/13_error_handling/errors2.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/13_error_handling/errors3.rs b/solutions/13_error_handling/errors3.rs index 70b786d..4e18198 100644 --- a/solutions/13_error_handling/errors3.rs +++ b/solutions/13_error_handling/errors3.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/13_error_handling/errors4.rs b/solutions/13_error_handling/errors4.rs index 70b786d..4e18198 100644 --- a/solutions/13_error_handling/errors4.rs +++ b/solutions/13_error_handling/errors4.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/13_error_handling/errors5.rs b/solutions/13_error_handling/errors5.rs index 70b786d..4e18198 100644 --- a/solutions/13_error_handling/errors5.rs +++ b/solutions/13_error_handling/errors5.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/13_error_handling/errors6.rs b/solutions/13_error_handling/errors6.rs index 70b786d..4e18198 100644 --- a/solutions/13_error_handling/errors6.rs +++ b/solutions/13_error_handling/errors6.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/14_generics/generics1.rs b/solutions/14_generics/generics1.rs index 70b786d..4e18198 100644 --- a/solutions/14_generics/generics1.rs +++ b/solutions/14_generics/generics1.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/14_generics/generics2.rs b/solutions/14_generics/generics2.rs index 70b786d..4e18198 100644 --- a/solutions/14_generics/generics2.rs +++ b/solutions/14_generics/generics2.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/15_traits/traits1.rs b/solutions/15_traits/traits1.rs index 70b786d..4e18198 100644 --- a/solutions/15_traits/traits1.rs +++ b/solutions/15_traits/traits1.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/15_traits/traits2.rs b/solutions/15_traits/traits2.rs index 70b786d..4e18198 100644 --- a/solutions/15_traits/traits2.rs +++ b/solutions/15_traits/traits2.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/15_traits/traits3.rs b/solutions/15_traits/traits3.rs index 70b786d..4e18198 100644 --- a/solutions/15_traits/traits3.rs +++ b/solutions/15_traits/traits3.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/15_traits/traits4.rs b/solutions/15_traits/traits4.rs index 70b786d..4e18198 100644 --- a/solutions/15_traits/traits4.rs +++ b/solutions/15_traits/traits4.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/15_traits/traits5.rs b/solutions/15_traits/traits5.rs index 70b786d..4e18198 100644 --- a/solutions/15_traits/traits5.rs +++ b/solutions/15_traits/traits5.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/16_lifetimes/lifetimes1.rs b/solutions/16_lifetimes/lifetimes1.rs index 70b786d..4e18198 100644 --- a/solutions/16_lifetimes/lifetimes1.rs +++ b/solutions/16_lifetimes/lifetimes1.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/16_lifetimes/lifetimes2.rs b/solutions/16_lifetimes/lifetimes2.rs index 70b786d..4e18198 100644 --- a/solutions/16_lifetimes/lifetimes2.rs +++ b/solutions/16_lifetimes/lifetimes2.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/16_lifetimes/lifetimes3.rs b/solutions/16_lifetimes/lifetimes3.rs index 70b786d..4e18198 100644 --- a/solutions/16_lifetimes/lifetimes3.rs +++ b/solutions/16_lifetimes/lifetimes3.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/17_tests/tests1.rs b/solutions/17_tests/tests1.rs index 70b786d..4e18198 100644 --- a/solutions/17_tests/tests1.rs +++ b/solutions/17_tests/tests1.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/17_tests/tests2.rs b/solutions/17_tests/tests2.rs index 70b786d..4e18198 100644 --- a/solutions/17_tests/tests2.rs +++ b/solutions/17_tests/tests2.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/17_tests/tests3.rs b/solutions/17_tests/tests3.rs index 70b786d..4e18198 100644 --- a/solutions/17_tests/tests3.rs +++ b/solutions/17_tests/tests3.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/17_tests/tests4.rs b/solutions/17_tests/tests4.rs index 70b786d..4e18198 100644 --- a/solutions/17_tests/tests4.rs +++ b/solutions/17_tests/tests4.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/18_iterators/iterators1.rs b/solutions/18_iterators/iterators1.rs index 70b786d..4e18198 100644 --- a/solutions/18_iterators/iterators1.rs +++ b/solutions/18_iterators/iterators1.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/18_iterators/iterators2.rs b/solutions/18_iterators/iterators2.rs index 70b786d..4e18198 100644 --- a/solutions/18_iterators/iterators2.rs +++ b/solutions/18_iterators/iterators2.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/18_iterators/iterators3.rs b/solutions/18_iterators/iterators3.rs index 70b786d..4e18198 100644 --- a/solutions/18_iterators/iterators3.rs +++ b/solutions/18_iterators/iterators3.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/18_iterators/iterators4.rs b/solutions/18_iterators/iterators4.rs index 70b786d..4e18198 100644 --- a/solutions/18_iterators/iterators4.rs +++ b/solutions/18_iterators/iterators4.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/18_iterators/iterators5.rs b/solutions/18_iterators/iterators5.rs index 70b786d..4e18198 100644 --- a/solutions/18_iterators/iterators5.rs +++ b/solutions/18_iterators/iterators5.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/19_smart_pointers/arc1.rs b/solutions/19_smart_pointers/arc1.rs index 70b786d..4e18198 100644 --- a/solutions/19_smart_pointers/arc1.rs +++ b/solutions/19_smart_pointers/arc1.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/19_smart_pointers/box1.rs b/solutions/19_smart_pointers/box1.rs index 70b786d..4e18198 100644 --- a/solutions/19_smart_pointers/box1.rs +++ b/solutions/19_smart_pointers/box1.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/19_smart_pointers/cow1.rs b/solutions/19_smart_pointers/cow1.rs index 70b786d..4e18198 100644 --- a/solutions/19_smart_pointers/cow1.rs +++ b/solutions/19_smart_pointers/cow1.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/19_smart_pointers/rc1.rs b/solutions/19_smart_pointers/rc1.rs index 70b786d..4e18198 100644 --- a/solutions/19_smart_pointers/rc1.rs +++ b/solutions/19_smart_pointers/rc1.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/20_threads/threads1.rs b/solutions/20_threads/threads1.rs index 70b786d..4e18198 100644 --- a/solutions/20_threads/threads1.rs +++ b/solutions/20_threads/threads1.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/20_threads/threads2.rs b/solutions/20_threads/threads2.rs index 70b786d..4e18198 100644 --- a/solutions/20_threads/threads2.rs +++ b/solutions/20_threads/threads2.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/20_threads/threads3.rs b/solutions/20_threads/threads3.rs index 70b786d..4e18198 100644 --- a/solutions/20_threads/threads3.rs +++ b/solutions/20_threads/threads3.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/21_macros/macros1.rs b/solutions/21_macros/macros1.rs index 70b786d..4e18198 100644 --- a/solutions/21_macros/macros1.rs +++ b/solutions/21_macros/macros1.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/21_macros/macros2.rs b/solutions/21_macros/macros2.rs index 70b786d..4e18198 100644 --- a/solutions/21_macros/macros2.rs +++ b/solutions/21_macros/macros2.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/21_macros/macros3.rs b/solutions/21_macros/macros3.rs index 70b786d..4e18198 100644 --- a/solutions/21_macros/macros3.rs +++ b/solutions/21_macros/macros3.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/21_macros/macros4.rs b/solutions/21_macros/macros4.rs index 70b786d..4e18198 100644 --- a/solutions/21_macros/macros4.rs +++ b/solutions/21_macros/macros4.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/22_clippy/clippy1.rs b/solutions/22_clippy/clippy1.rs index 70b786d..4e18198 100644 --- a/solutions/22_clippy/clippy1.rs +++ b/solutions/22_clippy/clippy1.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/22_clippy/clippy2.rs b/solutions/22_clippy/clippy2.rs index 70b786d..4e18198 100644 --- a/solutions/22_clippy/clippy2.rs +++ b/solutions/22_clippy/clippy2.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/22_clippy/clippy3.rs b/solutions/22_clippy/clippy3.rs index 70b786d..4e18198 100644 --- a/solutions/22_clippy/clippy3.rs +++ b/solutions/22_clippy/clippy3.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/23_conversions/as_ref_mut.rs b/solutions/23_conversions/as_ref_mut.rs index 70b786d..4e18198 100644 --- a/solutions/23_conversions/as_ref_mut.rs +++ b/solutions/23_conversions/as_ref_mut.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/23_conversions/from_into.rs b/solutions/23_conversions/from_into.rs index 70b786d..4e18198 100644 --- a/solutions/23_conversions/from_into.rs +++ b/solutions/23_conversions/from_into.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/23_conversions/from_str.rs b/solutions/23_conversions/from_str.rs index 70b786d..4e18198 100644 --- a/solutions/23_conversions/from_str.rs +++ b/solutions/23_conversions/from_str.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/23_conversions/try_from_into.rs b/solutions/23_conversions/try_from_into.rs index 70b786d..4e18198 100644 --- a/solutions/23_conversions/try_from_into.rs +++ b/solutions/23_conversions/try_from_into.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/23_conversions/using_as.rs b/solutions/23_conversions/using_as.rs index 70b786d..4e18198 100644 --- a/solutions/23_conversions/using_as.rs +++ b/solutions/23_conversions/using_as.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/quizzes/quiz1.rs b/solutions/quizzes/quiz1.rs index 70b786d..4e18198 100644 --- a/solutions/quizzes/quiz1.rs +++ b/solutions/quizzes/quiz1.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/quizzes/quiz2.rs b/solutions/quizzes/quiz2.rs index 70b786d..4e18198 100644 --- a/solutions/quizzes/quiz2.rs +++ b/solutions/quizzes/quiz2.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 diff --git a/solutions/quizzes/quiz3.rs b/solutions/quizzes/quiz3.rs index 70b786d..4e18198 100644 --- a/solutions/quizzes/quiz3.rs +++ b/solutions/quizzes/quiz3.rs @@ -1 +1 @@ -// TODO +// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 -- cgit v1.2.3 From 835ec7262247a341295c1d6f3772901a5fad5148 Mon Sep 17 00:00:00 2001 From: mo8it Date: Fri, 21 Jun 2024 14:52:11 +0200 Subject: vecs2 solution + significant change to have a better comparison between both methods --- exercises/05_vecs/vecs2.rs | 62 +++++++++++++++++++++++++++------------------- rustlings-macros/info.toml | 11 +++----- solutions/05_vecs/vecs2.rs | 51 +++++++++++++++++++++++++++++++++++++- 3 files changed, 90 insertions(+), 34 deletions(-) (limited to 'solutions/05_vecs/vecs2.rs') diff --git a/exercises/05_vecs/vecs2.rs b/exercises/05_vecs/vecs2.rs index e72209c..a9be258 100644 --- a/exercises/05_vecs/vecs2.rs +++ b/exercises/05_vecs/vecs2.rs @@ -1,25 +1,32 @@ -// A Vec of even numbers is given. Your task is to complete the loop so that -// each number in the Vec is multiplied by 2. -// -// Make me pass the test! - -fn vec_loop(mut v: Vec) -> Vec { - for element in v.iter_mut() { - // TODO: Fill this up so that each element in the Vec `v` is - // multiplied by 2. - ??? +fn vec_loop(input: &[i32]) -> Vec { + let mut output = Vec::new(); + + for element in input { + // TODO: Multiply each element in the `input` slice by 2 and push it to + // the `output` vector. } - // At this point, `v` should be equal to [4, 8, 12, 16, 20]. - v + output +} + +fn vec_map_example(input: &[i32]) -> Vec { + // An example of collecting a vector after mapping. + // We map each element of the `input` slice to its value plus 1. + // If the input is `[1, 2, 3]`, the output is `[2, 3, 4]`. + input.iter().map(|element| element + 1).collect() } -fn vec_map(v: &Vec) -> Vec { - v.iter().map(|element| { - // TODO: Do the same thing as above - but instead of mutating the - // Vec, you can just return the new number! - ??? - }).collect() +fn vec_map(input: &[i32]) -> Vec { + // TODO: Here, we also want to multiply each element in the `input` slice + // by 2, but with iterator mapping instead of manually pushing into an empty + // vector. + // See the example in the function `vec_map_example` above. + input + .iter() + .map(|element| { + // ??? + }) + .collect() } fn main() { @@ -32,17 +39,22 @@ mod tests { #[test] fn test_vec_loop() { - let v: Vec = (1..).filter(|x| x % 2 == 0).take(5).collect(); - let ans = vec_loop(v.clone()); + let input = [2, 4, 6, 8, 10]; + let ans = vec_loop(&input); + assert_eq!(ans, [4, 8, 12, 16, 20]); + } - assert_eq!(ans, v.iter().map(|x| x * 2).collect::>()); + #[test] + fn test_vec_map_example() { + let input = [1, 2, 3]; + let ans = vec_map_example(&input); + assert_eq!(ans, [2, 3, 4]); } #[test] fn test_vec_map() { - let v: Vec = (1..).filter(|x| x % 2 == 0).take(5).collect(); - let ans = vec_map(&v); - - assert_eq!(ans, v.iter().map(|x| x * 2).collect::>()); + let input = [2, 4, 6, 8, 10]; + let ans = vec_map(&input); + assert_eq!(ans, [4, 8, 12, 16, 20]); } } diff --git a/rustlings-macros/info.toml b/rustlings-macros/info.toml index 21a27dd..3edd1c6 100644 --- a/rustlings-macros/info.toml +++ b/rustlings-macros/info.toml @@ -319,15 +319,10 @@ of the Rust book to learn more. name = "vecs2" dir = "05_vecs" hint = """ -In the first function we are looping over the Vector and getting a reference to -one `element` at a time. +In the first function, we create an empty vector and want to push new elements +to it. -To modify the value of that `element` we need to use the `*` dereference -operator. You can learn more in this chapter of the Rust book: -https://doc.rust-lang.org/stable/book/ch08-01-vectors.html#iterating-over-the-values-in-a-vector - -In the second function this dereferencing is not necessary, because the `map` -function expects the new value to be returned. +In the second function, we map the values of the input and collect them into a vector. After you've completed both functions, decide for yourself which approach you like better. diff --git a/solutions/05_vecs/vecs2.rs b/solutions/05_vecs/vecs2.rs index 4e18198..32c1c0f 100644 --- a/solutions/05_vecs/vecs2.rs +++ b/solutions/05_vecs/vecs2.rs @@ -1 +1,50 @@ -// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 +fn vec_loop(input: &[i32]) -> Vec { + let mut output = Vec::new(); + + for element in input { + output.push(2 * element); + } + + output +} + +fn vec_map_example(input: &[i32]) -> Vec { + // An example of collecting a vector after mapping. + // We map each element of the `input` slice to its value plus 1. + // If the input is `[1, 2, 3]`, the output is `[2, 3, 4]`. + input.iter().map(|element| element + 1).collect() +} + +fn vec_map(input: &[i32]) -> Vec { + input.iter().map(|element| 2 * element).collect() +} + +fn main() { + // You can optionally experiment here. +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_vec_loop() { + let input = [2, 4, 6, 8, 10]; + let ans = vec_loop(&input); + assert_eq!(ans, [4, 8, 12, 16, 20]); + } + + #[test] + fn test_vec_map_example() { + let input = [1, 2, 3]; + let ans = vec_map_example(&input); + assert_eq!(ans, [2, 3, 4]); + } + + #[test] + fn test_vec_map() { + let input = [2, 4, 6, 8, 10]; + let ans = vec_map(&input); + assert_eq!(ans, [4, 8, 12, 16, 20]); + } +} -- cgit v1.2.3 From 6a79ada7f2afc668418c8fd15e2db622f3d833af Mon Sep 17 00:00:00 2001 From: mo8it Date: Fri, 21 Jun 2024 15:06:50 +0200 Subject: Add comment to vecs2 --- solutions/05_vecs/vecs2.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'solutions/05_vecs/vecs2.rs') diff --git a/solutions/05_vecs/vecs2.rs b/solutions/05_vecs/vecs2.rs index 32c1c0f..87f7625 100644 --- a/solutions/05_vecs/vecs2.rs +++ b/solutions/05_vecs/vecs2.rs @@ -16,6 +16,11 @@ fn vec_map_example(input: &[i32]) -> Vec { } fn vec_map(input: &[i32]) -> Vec { + // We will dive deeper into iterators, but for now, this is all what you + // had to do! + // Advanced note: This method is more efficient because it automatically + // preallocates enough capacity. This can be done manually in `vec_loop` + // using `Vec::with_capacity(input.len())` instead of `Vec::new()`. input.iter().map(|element| 2 * element).collect() } -- cgit v1.2.3