fix: showing unnecessary x is never used warnings

This commit is contained in:
Hussain 2024-09-12 03:07:13 +03:00
parent 2b7caf6fcb
commit 9f15c1bfee
No known key found for this signature in database
28 changed files with 56 additions and 0 deletions

View File

@ -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.

View File

@ -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" {

View File

@ -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" {

View File

@ -1,3 +1,5 @@
#![allow(dead_code)]
fn array_and_vec() -> ([i32; 4], Vec<i32>) {
let a = [10, 20, 30, 40]; // Array

View File

@ -1,3 +1,5 @@
#![allow(dead_code)]
fn vec_loop(input: &[i32]) -> Vec<i32> {
let mut output = Vec::new();

View File

@ -1,3 +1,5 @@
#![allow(dead_code)]
// TODO: Fix the compiler error in this function.
fn fill_vec(vec: Vec<i32>) -> Vec<i32> {
let vec = vec;

View File

@ -1,3 +1,5 @@
#![allow(dead_code)]
fn fill_vec(vec: Vec<i32>) -> Vec<i32> {
let mut vec = vec;

View File

@ -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<i32>) -> Vec<i32> {
vec.push(88);

View File

@ -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?

View File

@ -1,3 +1,5 @@
#![allow(dead_code)]
#[derive(Debug)]
struct Order {
name: String,

View File

@ -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.

View File

@ -1,3 +1,5 @@
#![allow(dead_code)]
struct Point {
x: u64,
y: u64,

View File

@ -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

View File

@ -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 "<team_1_name>,<team_2_name>,<team_1_goals>,<team_2_goals>"
// Example: "England,France,4,2" (England scored 4 goals, France 2).

View File

@ -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

View File

@ -1,3 +1,5 @@
#![allow(dead_code)]
#[derive(PartialEq, Debug)]
enum CreationError {
Negative,

View File

@ -1,3 +1,5 @@
#![allow(dead_code)]
// Using catch-all error types like `Box<dyn Error>` 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

View File

@ -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 {

View File

@ -1,3 +1,5 @@
#![allow(dead_code)]
trait AppendBar {
fn append_bar(self) -> Self;
}

View File

@ -1,3 +1,5 @@
#![allow(dead_code)]
// Tests are important to ensure that your code does what you think it should
// do.

View File

@ -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 {

View File

@ -1,3 +1,5 @@
#![allow(dead_code)]
struct Rectangle {
width: i32,
height: i32,

View File

@ -1,3 +1,5 @@
#![allow(dead_code)]
#[derive(Debug, PartialEq, Eq)]
enum DivisionError {
// Example: 42 / 0

View File

@ -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

View File

@ -1,3 +1,5 @@
#![allow(dead_code)]
// In this exercise, we want to express the concept of multiple owners via the
// `Rc<T>` 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

View File

@ -1,3 +1,5 @@
#![allow(dead_code)]
// This is a quiz for the following sections:
// - Variables
// - Functions

View File

@ -1,3 +1,5 @@
#![allow(dead_code)]
// This is a quiz for the following sections:
// - Strings
// - Vecs

View File

@ -1,3 +1,5 @@
#![allow(dead_code)]
// This quiz tests:
// - Generics
// - Traits