Remove unneeded pub

This commit is contained in:
mo8it 2024-05-22 15:04:12 +02:00
parent d0b843d6c4
commit 3bb71c6b0c
18 changed files with 30 additions and 30 deletions

View file

@ -1,5 +1,5 @@
pub fn bigger(a: i32, b: i32) -> i32 { fn bigger(a: i32, b: i32) -> i32 {
// Complete this function to return the bigger number! // TODO: Complete this function to return the bigger number!
// If both numbers are equal, any of them can be returned. // If both numbers are equal, any of them can be returned.
// Do not use: // Do not use:
// - another function call // - another function call

View file

@ -1,7 +1,7 @@
// Step 1: Make me compile! // Step 1: Make me compile!
// Step 2: Get the bar_for_fuzz and default_to_baz tests passing! // 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" { if fizzish == "fizz" {
"foo" "foo"
} else { } else {

View file

@ -1,4 +1,4 @@
pub fn animal_habitat(animal: &str) -> &'static str { fn animal_habitat(animal: &str) -> &'static str {
let identifier = if animal == "crab" { let identifier = if animal == "crab" {
1 1
} else if animal == "gopher" { } else if animal == "gopher" {

View file

@ -8,7 +8,7 @@ fn main() {
// You can optionally experiment here. // You can optionally experiment here.
} }
pub fn generate_nametag_text(name: String) -> Option<String> { fn generate_nametag_text(name: String) -> Option<String> {
if name.is_empty() { if name.is_empty() {
// Empty names aren't allowed. // Empty names aren't allowed.
None None

View file

@ -16,7 +16,7 @@
use std::num::ParseIntError; use std::num::ParseIntError;
pub fn total_cost(item_quantity: &str) -> Result<i32, ParseIntError> { fn total_cost(item_quantity: &str) -> Result<i32, ParseIntError> {
let processing_fee = 1; let processing_fee = 1;
let cost_per_item = 5; let cost_per_item = 5;
let qty = item_quantity.parse::<i32>(); let qty = item_quantity.parse::<i32>();

View file

@ -18,7 +18,7 @@ fn main() {
} }
} }
pub fn total_cost(item_quantity: &str) -> Result<i32, ParseIntError> { fn total_cost(item_quantity: &str) -> Result<i32, ParseIntError> {
let processing_fee = 1; let processing_fee = 1;
let cost_per_item = 5; let cost_per_item = 5;
let qty = item_quantity.parse::<i32>()?; let qty = item_quantity.parse::<i32>()?;

View file

@ -6,7 +6,7 @@ struct Wrapper {
} }
impl Wrapper { impl Wrapper {
pub fn new(value: u32) -> Self { fn new(value: u32) -> Self {
Wrapper { value } Wrapper { value }
} }
} }

View file

@ -3,7 +3,7 @@
// //
// Consider what you can add to the Licensed trait. // Consider what you can add to the Licensed trait.
pub trait Licensed { trait Licensed {
fn licensing_info(&self) -> String; fn licensing_info(&self) -> String;
} }

View file

@ -2,7 +2,7 @@
// //
// Don't change any line other than the marked one. // Don't change any line other than the marked one.
pub trait Licensed { trait Licensed {
fn licensing_info(&self) -> String { fn licensing_info(&self) -> String {
"some information".to_string() "some information".to_string()
} }

View file

@ -2,13 +2,13 @@
// //
// Don't change any line other than the marked one. // Don't change any line other than the marked one.
pub trait SomeTrait { trait SomeTrait {
fn some_function(&self) -> bool { fn some_function(&self) -> bool {
true true
} }
} }
pub trait OtherTrait { trait OtherTrait {
fn other_function(&self) -> bool { fn other_function(&self) -> bool {
true true
} }

View file

@ -2,7 +2,7 @@
// the test passes. Then write a second test that tests whether we get the // 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)`. // 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 num % 2 == 0
} }

View file

@ -7,7 +7,7 @@ struct Rectangle {
impl Rectangle { impl Rectangle {
// Only change the test functions themselves // 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 { if width <= 0 || height <= 0 {
panic!("Rectangle width and height cannot be negative!") panic!("Rectangle width and height cannot be negative!")
} }

View file

@ -4,7 +4,7 @@
// Step 1. // Step 1.
// Complete the `capitalize_first` function. // Complete the `capitalize_first` function.
// "hello" -> "Hello" // "hello" -> "Hello"
pub fn capitalize_first(input: &str) -> String { fn capitalize_first(input: &str) -> String {
let mut c = input.chars(); let mut c = input.chars();
match c.next() { match c.next() {
None => String::new(), 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. // Apply the `capitalize_first` function to a slice of string slices.
// Return a vector of strings. // Return a vector of strings.
// ["hello", "world"] -> ["Hello", "World"] // ["hello", "world"] -> ["Hello", "World"]
pub fn capitalize_words_vector(words: &[&str]) -> Vec<String> { fn capitalize_words_vector(words: &[&str]) -> Vec<String> {
vec![] vec![]
} }
@ -24,7 +24,7 @@ pub fn capitalize_words_vector(words: &[&str]) -> Vec<String> {
// Apply the `capitalize_first` function again to a slice of string slices. // Apply the `capitalize_first` function again to a slice of string slices.
// Return a single string. // Return a single string.
// ["hello", " ", "world"] -> "Hello World" // ["hello", " ", "world"] -> "Hello World"
pub fn capitalize_words_string(words: &[&str]) -> String { fn capitalize_words_string(words: &[&str]) -> String {
String::new() String::new()
} }

View file

@ -5,20 +5,20 @@
// list_of_results functions. // list_of_results functions.
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
pub enum DivisionError { enum DivisionError {
NotDivisible(NotDivisibleError), NotDivisible(NotDivisibleError),
DivideByZero, DivideByZero,
} }
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
pub struct NotDivisibleError { struct NotDivisibleError {
dividend: i32, dividend: i32,
divisor: i32, divisor: i32,
} }
// Calculate `a` divided by `b` if `a` is evenly divisible by `b`. // Calculate `a` divided by `b` if `a` is evenly divisible by `b`.
// Otherwise, return a suitable error. // Otherwise, return a suitable error.
pub fn divide(a: i32, b: i32) -> Result<i32, DivisionError> { fn divide(a: i32, b: i32) -> Result<i32, DivisionError> {
todo!(); todo!();
} }

View file

@ -1,4 +1,4 @@
pub fn factorial(num: u64) -> u64 { fn factorial(num: u64) -> u64 {
// Complete this function to return the factorial of num // Complete this function to return the factorial of num
// Do not use: // Do not use:
// - early returns (using the `return` keyword explicitly) // - early returns (using the `return` keyword explicitly)

View file

@ -15,7 +15,7 @@
// Note: the tests should not be changed // Note: the tests should not be changed
#[derive(PartialEq, Debug)] #[derive(PartialEq, Debug)]
pub enum List { enum List {
Cons(i32, List), Cons(i32, List),
Nil, Nil,
} }
@ -28,11 +28,11 @@ fn main() {
); );
} }
pub fn create_empty_list() -> List { fn create_empty_list() -> List {
todo!() todo!()
} }
pub fn create_non_empty_list() -> List { fn create_non_empty_list() -> List {
todo!() todo!()
} }

View file

@ -16,7 +16,7 @@
// the first element is the string, the second one is the command. // the first element is the string, the second one is the command.
// - The output element is going to be a Vector of strings. // - The output element is going to be a Vector of strings.
pub enum Command { enum Command {
Uppercase, Uppercase,
Trim, Trim,
Append(usize), Append(usize),

View file

@ -12,14 +12,14 @@
// to support alphabetical report cards. Change the Grade in the second test to // to support alphabetical report cards. Change the Grade in the second test to
// "A+" to show that your changes allow alphabetical grades. // "A+" to show that your changes allow alphabetical grades.
pub struct ReportCard { struct ReportCard {
pub grade: f32, grade: f32,
pub student_name: String, student_name: String,
pub student_age: u8, student_age: u8,
} }
impl ReportCard { impl ReportCard {
pub fn print(&self) -> String { fn print(&self) -> String {
format!( format!(
"{} ({}) - achieved a grade of {}", "{} ({}) - achieved a grade of {}",
&self.student_name, &self.student_age, &self.grade &self.student_name, &self.student_age, &self.grade