From 3bb71c6b0c9d58e421f79d914f5483cb5a98af0b Mon Sep 17 00:00:00 2001 From: mo8it Date: Wed, 22 May 2024 15:04:12 +0200 Subject: [PATCH] Remove unneeded pub --- exercises/03_if/if1.rs | 4 ++-- exercises/03_if/if2.rs | 2 +- exercises/03_if/if3.rs | 2 +- exercises/13_error_handling/errors1.rs | 2 +- exercises/13_error_handling/errors2.rs | 2 +- exercises/13_error_handling/errors3.rs | 2 +- exercises/14_generics/generics2.rs | 2 +- exercises/15_traits/traits3.rs | 2 +- exercises/15_traits/traits4.rs | 2 +- exercises/15_traits/traits5.rs | 4 ++-- exercises/17_tests/tests3.rs | 2 +- exercises/17_tests/tests4.rs | 2 +- exercises/18_iterators/iterators2.rs | 6 +++--- exercises/18_iterators/iterators3.rs | 6 +++--- exercises/18_iterators/iterators4.rs | 2 +- exercises/19_smart_pointers/box1.rs | 6 +++--- exercises/quizzes/quiz2.rs | 2 +- exercises/quizzes/quiz3.rs | 10 +++++----- 18 files changed, 30 insertions(+), 30 deletions(-) diff --git a/exercises/03_if/if1.rs b/exercises/03_if/if1.rs index 52dee0b5..e5a3c5a5 100644 --- a/exercises/03_if/if1.rs +++ b/exercises/03_if/if1.rs @@ -1,5 +1,5 @@ -pub fn bigger(a: i32, b: i32) -> i32 { - // Complete this function to return the bigger number! +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. // Do not use: // - another function call diff --git a/exercises/03_if/if2.rs b/exercises/03_if/if2.rs index a06bba55..d834ab27 100644 --- a/exercises/03_if/if2.rs +++ b/exercises/03_if/if2.rs @@ -1,7 +1,7 @@ // Step 1: Make me compile! // Step 2: Get the bar_for_fuzz and default_to_baz tests passing! -pub fn foo_if_fizz(fizzish: &str) -> &str { +fn foo_if_fizz(fizzish: &str) -> &str { if fizzish == "fizz" { "foo" } else { diff --git a/exercises/03_if/if3.rs b/exercises/03_if/if3.rs index 1d9b7c25..ff6fee64 100644 --- a/exercises/03_if/if3.rs +++ b/exercises/03_if/if3.rs @@ -1,4 +1,4 @@ -pub fn animal_habitat(animal: &str) -> &'static str { +fn animal_habitat(animal: &str) -> &'static str { let identifier = if animal == "crab" { 1 } else if animal == "gopher" { diff --git a/exercises/13_error_handling/errors1.rs b/exercises/13_error_handling/errors1.rs index 15a3716d..e3e04823 100644 --- a/exercises/13_error_handling/errors1.rs +++ b/exercises/13_error_handling/errors1.rs @@ -8,7 +8,7 @@ fn main() { // You can optionally experiment here. } -pub fn generate_nametag_text(name: String) -> Option { +fn generate_nametag_text(name: String) -> Option { if name.is_empty() { // Empty names aren't allowed. None diff --git a/exercises/13_error_handling/errors2.rs b/exercises/13_error_handling/errors2.rs index e39aa959..345a0eef 100644 --- a/exercises/13_error_handling/errors2.rs +++ b/exercises/13_error_handling/errors2.rs @@ -16,7 +16,7 @@ use std::num::ParseIntError; -pub fn total_cost(item_quantity: &str) -> Result { +fn total_cost(item_quantity: &str) -> Result { let processing_fee = 1; let cost_per_item = 5; let qty = item_quantity.parse::(); diff --git a/exercises/13_error_handling/errors3.rs b/exercises/13_error_handling/errors3.rs index 5661f17b..2ef84f98 100644 --- a/exercises/13_error_handling/errors3.rs +++ b/exercises/13_error_handling/errors3.rs @@ -18,7 +18,7 @@ fn main() { } } -pub fn total_cost(item_quantity: &str) -> Result { +fn total_cost(item_quantity: &str) -> Result { let processing_fee = 1; let cost_per_item = 5; let qty = item_quantity.parse::()?; diff --git a/exercises/14_generics/generics2.rs b/exercises/14_generics/generics2.rs index cbb9b5f9..6cdcdaf5 100644 --- a/exercises/14_generics/generics2.rs +++ b/exercises/14_generics/generics2.rs @@ -6,7 +6,7 @@ struct Wrapper { } impl Wrapper { - pub fn new(value: u32) -> Self { + fn new(value: u32) -> Self { Wrapper { value } } } diff --git a/exercises/15_traits/traits3.rs b/exercises/15_traits/traits3.rs index 9a2365ae..66da235f 100644 --- a/exercises/15_traits/traits3.rs +++ b/exercises/15_traits/traits3.rs @@ -3,7 +3,7 @@ // // Consider what you can add to the Licensed trait. -pub trait Licensed { +trait Licensed { fn licensing_info(&self) -> String; } diff --git a/exercises/15_traits/traits4.rs b/exercises/15_traits/traits4.rs index 7af30b57..ed63f6e1 100644 --- a/exercises/15_traits/traits4.rs +++ b/exercises/15_traits/traits4.rs @@ -2,7 +2,7 @@ // // Don't change any line other than the marked one. -pub trait Licensed { +trait Licensed { fn licensing_info(&self) -> String { "some information".to_string() } diff --git a/exercises/15_traits/traits5.rs b/exercises/15_traits/traits5.rs index 9a45bb76..3e62283f 100644 --- a/exercises/15_traits/traits5.rs +++ b/exercises/15_traits/traits5.rs @@ -2,13 +2,13 @@ // // Don't change any line other than the marked one. -pub trait SomeTrait { +trait SomeTrait { fn some_function(&self) -> bool { true } } -pub trait OtherTrait { +trait OtherTrait { fn other_function(&self) -> bool { true } diff --git a/exercises/17_tests/tests3.rs b/exercises/17_tests/tests3.rs index 3b4e1990..d1cb4892 100644 --- a/exercises/17_tests/tests3.rs +++ b/exercises/17_tests/tests3.rs @@ -2,7 +2,7 @@ // the test passes. Then write a second test that tests whether we get the // result we expect to get when we call `is_even(5)`. -pub fn is_even(num: i32) -> bool { +fn is_even(num: i32) -> bool { num % 2 == 0 } diff --git a/exercises/17_tests/tests4.rs b/exercises/17_tests/tests4.rs index 35a9a3b5..4303ed06 100644 --- a/exercises/17_tests/tests4.rs +++ b/exercises/17_tests/tests4.rs @@ -7,7 +7,7 @@ struct Rectangle { impl Rectangle { // Only change the test functions themselves - pub fn new(width: i32, height: i32) -> Self { + fn new(width: i32, height: i32) -> Self { if width <= 0 || height <= 0 { panic!("Rectangle width and height cannot be negative!") } diff --git a/exercises/18_iterators/iterators2.rs b/exercises/18_iterators/iterators2.rs index df1fa838..8d8909bf 100644 --- a/exercises/18_iterators/iterators2.rs +++ b/exercises/18_iterators/iterators2.rs @@ -4,7 +4,7 @@ // Step 1. // Complete the `capitalize_first` function. // "hello" -> "Hello" -pub fn capitalize_first(input: &str) -> String { +fn capitalize_first(input: &str) -> String { let mut c = input.chars(); match c.next() { None => String::new(), @@ -16,7 +16,7 @@ pub fn capitalize_first(input: &str) -> String { // Apply the `capitalize_first` function to a slice of string slices. // Return a vector of strings. // ["hello", "world"] -> ["Hello", "World"] -pub fn capitalize_words_vector(words: &[&str]) -> Vec { +fn capitalize_words_vector(words: &[&str]) -> Vec { vec![] } @@ -24,7 +24,7 @@ pub fn capitalize_words_vector(words: &[&str]) -> Vec { // Apply the `capitalize_first` function again to a slice of string slices. // Return a single string. // ["hello", " ", "world"] -> "Hello World" -pub fn capitalize_words_string(words: &[&str]) -> String { +fn capitalize_words_string(words: &[&str]) -> String { String::new() } diff --git a/exercises/18_iterators/iterators3.rs b/exercises/18_iterators/iterators3.rs index 9f106aa8..dfe40149 100644 --- a/exercises/18_iterators/iterators3.rs +++ b/exercises/18_iterators/iterators3.rs @@ -5,20 +5,20 @@ // list_of_results functions. #[derive(Debug, PartialEq, Eq)] -pub enum DivisionError { +enum DivisionError { NotDivisible(NotDivisibleError), DivideByZero, } #[derive(Debug, PartialEq, Eq)] -pub struct NotDivisibleError { +struct NotDivisibleError { dividend: i32, divisor: i32, } // Calculate `a` divided by `b` if `a` is evenly divisible by `b`. // Otherwise, return a suitable error. -pub fn divide(a: i32, b: i32) -> Result { +fn divide(a: i32, b: i32) -> Result { todo!(); } diff --git a/exercises/18_iterators/iterators4.rs b/exercises/18_iterators/iterators4.rs index 60c7b8d1..ae4d502d 100644 --- a/exercises/18_iterators/iterators4.rs +++ b/exercises/18_iterators/iterators4.rs @@ -1,4 +1,4 @@ -pub fn factorial(num: u64) -> u64 { +fn factorial(num: u64) -> u64 { // Complete this function to return the factorial of num // Do not use: // - early returns (using the `return` keyword explicitly) diff --git a/exercises/19_smart_pointers/box1.rs b/exercises/19_smart_pointers/box1.rs index 226a1177..908c9232 100644 --- a/exercises/19_smart_pointers/box1.rs +++ b/exercises/19_smart_pointers/box1.rs @@ -15,7 +15,7 @@ // Note: the tests should not be changed #[derive(PartialEq, Debug)] -pub enum List { +enum List { Cons(i32, List), Nil, } @@ -28,11 +28,11 @@ fn main() { ); } -pub fn create_empty_list() -> List { +fn create_empty_list() -> List { todo!() } -pub fn create_non_empty_list() -> List { +fn create_non_empty_list() -> List { todo!() } diff --git a/exercises/quizzes/quiz2.rs b/exercises/quizzes/quiz2.rs index 0a29e781..e01e3f1d 100644 --- a/exercises/quizzes/quiz2.rs +++ b/exercises/quizzes/quiz2.rs @@ -16,7 +16,7 @@ // the first element is the string, the second one is the command. // - The output element is going to be a Vector of strings. -pub enum Command { +enum Command { Uppercase, Trim, Append(usize), diff --git a/exercises/quizzes/quiz3.rs b/exercises/quizzes/quiz3.rs index f255cb5d..f3cb1bcf 100644 --- a/exercises/quizzes/quiz3.rs +++ b/exercises/quizzes/quiz3.rs @@ -12,14 +12,14 @@ // to support alphabetical report cards. Change the Grade in the second test to // "A+" to show that your changes allow alphabetical grades. -pub struct ReportCard { - pub grade: f32, - pub student_name: String, - pub student_age: u8, +struct ReportCard { + grade: f32, + student_name: String, + student_age: u8, } impl ReportCard { - pub fn print(&self) -> String { + fn print(&self) -> String { format!( "{} ({}) - achieved a grade of {}", &self.student_name, &self.student_age, &self.grade