From 9f15c1bfee7153fe02c2e9c280da10052b744e81 Mon Sep 17 00:00:00 2001 From: Hussain Date: Thu, 12 Sep 2024 03:07:13 +0300 Subject: [PATCH] fix: showing unnecessary `x is never used` warnings --- exercises/03_if/if1.rs | 2 ++ exercises/03_if/if2.rs | 2 ++ exercises/03_if/if3.rs | 2 ++ exercises/05_vecs/vecs1.rs | 2 ++ exercises/05_vecs/vecs2.rs | 2 ++ exercises/06_move_semantics/move_semantics1.rs | 2 ++ exercises/06_move_semantics/move_semantics2.rs | 2 ++ exercises/06_move_semantics/move_semantics3.rs | 2 ++ exercises/07_structs/structs1.rs | 2 ++ exercises/07_structs/structs2.rs | 2 ++ exercises/07_structs/structs3.rs | 2 ++ exercises/08_enums/enums3.rs | 2 ++ exercises/11_hashmaps/hashmaps2.rs | 2 ++ exercises/11_hashmaps/hashmaps3.rs | 2 ++ exercises/13_error_handling/errors1.rs | 2 ++ exercises/13_error_handling/errors4.rs | 2 ++ exercises/13_error_handling/errors6.rs | 2 ++ exercises/14_generics/generics2.rs | 2 ++ exercises/15_traits/traits2.rs | 2 ++ exercises/17_tests/tests1.rs | 2 ++ exercises/17_tests/tests2.rs | 2 ++ exercises/17_tests/tests3.rs | 2 ++ exercises/18_iterators/iterators3.rs | 2 ++ exercises/19_smart_pointers/cow1.rs | 2 ++ exercises/19_smart_pointers/rc1.rs | 2 ++ exercises/quizzes/quiz1.rs | 2 ++ exercises/quizzes/quiz2.rs | 2 ++ exercises/quizzes/quiz3.rs | 2 ++ 28 files changed, 56 insertions(+) diff --git a/exercises/03_if/if1.rs b/exercises/03_if/if1.rs index e5a3c5a5..9019f165 100644 --- a/exercises/03_if/if1.rs +++ b/exercises/03_if/if1.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + fn bigger(a: i32, b: i32) -> i32 { // TODO: Complete this function to return the bigger number! // If both numbers are equal, any of them can be returned. diff --git a/exercises/03_if/if2.rs b/exercises/03_if/if2.rs index 593a77a7..9b06e792 100644 --- a/exercises/03_if/if2.rs +++ b/exercises/03_if/if2.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + // TODO: Fix the compiler error on this function. fn foo_if_fizz(fizzish: &str) -> &str { if fizzish == "fizz" { diff --git a/exercises/03_if/if3.rs b/exercises/03_if/if3.rs index 89164eb2..c0597302 100644 --- a/exercises/03_if/if3.rs +++ b/exercises/03_if/if3.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + fn animal_habitat(animal: &str) -> &str { // TODO: Fix the compiler error in the statement below. let identifier = if animal == "crab" { diff --git a/exercises/05_vecs/vecs1.rs b/exercises/05_vecs/vecs1.rs index 68e1affa..d115dcc7 100644 --- a/exercises/05_vecs/vecs1.rs +++ b/exercises/05_vecs/vecs1.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + fn array_and_vec() -> ([i32; 4], Vec) { let a = [10, 20, 30, 40]; // Array diff --git a/exercises/05_vecs/vecs2.rs b/exercises/05_vecs/vecs2.rs index a9be2580..09d57c32 100644 --- a/exercises/05_vecs/vecs2.rs +++ b/exercises/05_vecs/vecs2.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + fn vec_loop(input: &[i32]) -> Vec { let mut output = Vec::new(); diff --git a/exercises/06_move_semantics/move_semantics1.rs b/exercises/06_move_semantics/move_semantics1.rs index 4eb3d618..59a88d74 100644 --- a/exercises/06_move_semantics/move_semantics1.rs +++ b/exercises/06_move_semantics/move_semantics1.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + // TODO: Fix the compiler error in this function. fn fill_vec(vec: Vec) -> Vec { let vec = vec; diff --git a/exercises/06_move_semantics/move_semantics2.rs b/exercises/06_move_semantics/move_semantics2.rs index a3ab7a0f..f32efa41 100644 --- a/exercises/06_move_semantics/move_semantics2.rs +++ b/exercises/06_move_semantics/move_semantics2.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + fn fill_vec(vec: Vec) -> Vec { let mut vec = vec; diff --git a/exercises/06_move_semantics/move_semantics3.rs b/exercises/06_move_semantics/move_semantics3.rs index 11dbbbeb..cba11289 100644 --- a/exercises/06_move_semantics/move_semantics3.rs +++ b/exercises/06_move_semantics/move_semantics3.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + // TODO: Fix the compiler error in the function without adding any new line. fn fill_vec(vec: Vec) -> Vec { vec.push(88); diff --git a/exercises/07_structs/structs1.rs b/exercises/07_structs/structs1.rs index 959c4c6a..f0928c32 100644 --- a/exercises/07_structs/structs1.rs +++ b/exercises/07_structs/structs1.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + struct ColorRegularStruct { // TODO: Add the fields that the test `regular_structs` expects. // What types should the fields have? What are the minimum and maximum values for RGB colors? diff --git a/exercises/07_structs/structs2.rs b/exercises/07_structs/structs2.rs index 79141af9..fbf25adc 100644 --- a/exercises/07_structs/structs2.rs +++ b/exercises/07_structs/structs2.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + #[derive(Debug)] struct Order { name: String, diff --git a/exercises/07_structs/structs3.rs b/exercises/07_structs/structs3.rs index 69e5ced7..d371093b 100644 --- a/exercises/07_structs/structs3.rs +++ b/exercises/07_structs/structs3.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + // Structs contain data, but can also have logic. In this exercise, we have // defined the `Package` struct, and we want to test some logic attached to it. diff --git a/exercises/08_enums/enums3.rs b/exercises/08_enums/enums3.rs index 66c4675f..5c3221dd 100644 --- a/exercises/08_enums/enums3.rs +++ b/exercises/08_enums/enums3.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + struct Point { x: u64, y: u64, diff --git a/exercises/11_hashmaps/hashmaps2.rs b/exercises/11_hashmaps/hashmaps2.rs index e9f53fea..ba29765c 100644 --- a/exercises/11_hashmaps/hashmaps2.rs +++ b/exercises/11_hashmaps/hashmaps2.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + // We're collecting different fruits to bake a delicious fruit cake. For this, // we have a basket, which we'll represent in the form of a hash map. The key // represents the name of each fruit we collect and the value represents how diff --git a/exercises/11_hashmaps/hashmaps3.rs b/exercises/11_hashmaps/hashmaps3.rs index 7e9584d1..c8475fc2 100644 --- a/exercises/11_hashmaps/hashmaps3.rs +++ b/exercises/11_hashmaps/hashmaps3.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + // A list of scores (one per line) of a soccer match is given. Each line is of // the form ",,," // Example: "England,France,4,2" (England scored 4 goals, France 2). diff --git a/exercises/13_error_handling/errors1.rs b/exercises/13_error_handling/errors1.rs index e07fddc3..eadf809a 100644 --- a/exercises/13_error_handling/errors1.rs +++ b/exercises/13_error_handling/errors1.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + // TODO: This function refuses to generate text to be printed on a nametag if // you pass it an empty string. It'd be nicer if it explained what the problem // was instead of just returning `None`. Thankfully, Rust has a similar diff --git a/exercises/13_error_handling/errors4.rs b/exercises/13_error_handling/errors4.rs index ba01e54b..264bc9c6 100644 --- a/exercises/13_error_handling/errors4.rs +++ b/exercises/13_error_handling/errors4.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + #[derive(PartialEq, Debug)] enum CreationError { Negative, diff --git a/exercises/13_error_handling/errors6.rs b/exercises/13_error_handling/errors6.rs index b1995e03..4c34deb7 100644 --- a/exercises/13_error_handling/errors6.rs +++ b/exercises/13_error_handling/errors6.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + // Using catch-all error types like `Box` isn't recommended for // library code where callers might want to make decisions based on the error // content instead of printing it out or propagating it further. Here, we define diff --git a/exercises/14_generics/generics2.rs b/exercises/14_generics/generics2.rs index 8908725b..d7df51c7 100644 --- a/exercises/14_generics/generics2.rs +++ b/exercises/14_generics/generics2.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + // This powerful wrapper provides the ability to store a positive integer value. // TODO: Rewrite it using a generic so that it supports wrapping ANY type. struct Wrapper { diff --git a/exercises/15_traits/traits2.rs b/exercises/15_traits/traits2.rs index d724dc28..d856cb82 100644 --- a/exercises/15_traits/traits2.rs +++ b/exercises/15_traits/traits2.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + trait AppendBar { fn append_bar(self) -> Self; } diff --git a/exercises/17_tests/tests1.rs b/exercises/17_tests/tests1.rs index 7529f9f0..954d1bc0 100644 --- a/exercises/17_tests/tests1.rs +++ b/exercises/17_tests/tests1.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + // Tests are important to ensure that your code does what you think it should // do. diff --git a/exercises/17_tests/tests2.rs b/exercises/17_tests/tests2.rs index 0c6573e8..d9f1a507 100644 --- a/exercises/17_tests/tests2.rs +++ b/exercises/17_tests/tests2.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + // Calculates the power of 2 using a bit shift. // `1 << n` is equivalent to "2 to the power of n". fn power_of_2(n: u8) -> u64 { diff --git a/exercises/17_tests/tests3.rs b/exercises/17_tests/tests3.rs index 822184ef..559d02bf 100644 --- a/exercises/17_tests/tests3.rs +++ b/exercises/17_tests/tests3.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + struct Rectangle { width: i32, height: i32, diff --git a/exercises/18_iterators/iterators3.rs b/exercises/18_iterators/iterators3.rs index 6b1eca17..077dd8a5 100644 --- a/exercises/18_iterators/iterators3.rs +++ b/exercises/18_iterators/iterators3.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + #[derive(Debug, PartialEq, Eq)] enum DivisionError { // Example: 42 / 0 diff --git a/exercises/19_smart_pointers/cow1.rs b/exercises/19_smart_pointers/cow1.rs index 15665007..4a749de3 100644 --- a/exercises/19_smart_pointers/cow1.rs +++ b/exercises/19_smart_pointers/cow1.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + // This exercise explores the `Cow` (Clone-On-Write) smart pointer. It can // enclose and provide immutable access to borrowed data and clone the data // lazily when mutation or ownership is required. The type is designed to work diff --git a/exercises/19_smart_pointers/rc1.rs b/exercises/19_smart_pointers/rc1.rs index 48e19dc0..4d6b6457 100644 --- a/exercises/19_smart_pointers/rc1.rs +++ b/exercises/19_smart_pointers/rc1.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + // In this exercise, we want to express the concept of multiple owners via the // `Rc` type. This is a model of our solar system - there is a `Sun` type and // multiple `Planet`s. The planets take ownership of the sun, indicating that diff --git a/exercises/quizzes/quiz1.rs b/exercises/quizzes/quiz1.rs index 04fb2aaf..41620d21 100644 --- a/exercises/quizzes/quiz1.rs +++ b/exercises/quizzes/quiz1.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + // This is a quiz for the following sections: // - Variables // - Functions diff --git a/exercises/quizzes/quiz2.rs b/exercises/quizzes/quiz2.rs index 2cddba90..c575aacf 100644 --- a/exercises/quizzes/quiz2.rs +++ b/exercises/quizzes/quiz2.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + // This is a quiz for the following sections: // - Strings // - Vecs diff --git a/exercises/quizzes/quiz3.rs b/exercises/quizzes/quiz3.rs index c877c5f8..3f728237 100644 --- a/exercises/quizzes/quiz3.rs +++ b/exercises/quizzes/quiz3.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + // This quiz tests: // - Generics // - Traits