diff --git a/exercises/clippy/clippy1.rs b/exercises/clippy/clippy1.rs index d1166816..38463601 100644 --- a/exercises/clippy/clippy1.rs +++ b/exercises/clippy/clippy1.rs @@ -9,27 +9,10 @@ // Execute `rustlings hint clippy1` or use the `hint` watch subcommand for a // hint. -<<<<<<< HEAD fn main() { let x = 1.2331f64; let y = 1.2332f64; if (x - y).abs() < 0.00001 { println!("Success!"); } -======= -// I AM NOT DONE - -use std::f32; - -fn main() { - let pi = 3.14f32; - let radius = 5.00f32; - - let area = pi * f32::powi(radius, 2); - - println!( - "The area of a circle with radius {:.2} is {:.5}!", - radius, area - ) ->>>>>>> 11d8aea96f2c744d970ed1ffb38785cf5b511e5e } diff --git a/exercises/conversions/from_into.rs b/exercises/conversions/from_into.rs index ea4eced7..c4899825 100644 --- a/exercises/conversions/from_into.rs +++ b/exercises/conversions/from_into.rs @@ -24,18 +24,11 @@ impl Default for Person { } } -<<<<<<< HEAD // Your task is to complete this implementation // in order for the line `let p = Person::from("Mark,20")` to compile // Please note that you'll need to parse the age component into a `usize` // with something like `"4".parse::()`. The outcome of this needs to // be handled appropriately. -======= -// Your task is to complete this implementation in order for the line `let p = -// Person::from("Mark,20")` to compile Please note that you'll need to parse the -// age component into a `usize` with something like `"4".parse::()`. The -// outcome of this needs to be handled appropriately. ->>>>>>> 11d8aea96f2c744d970ed1ffb38785cf5b511e5e // // Steps: // 1. If the length of the provided string is 0, then return the default of diff --git a/exercises/conversions/using_as.rs b/exercises/conversions/using_as.rs index c5cdce08..ce15bcad 100644 --- a/exercises/conversions/using_as.rs +++ b/exercises/conversions/using_as.rs @@ -10,20 +10,12 @@ // Execute `rustlings hint using_as` or use the `hint` watch subcommand for a // hint. -<<<<<<< HEAD // The goal is to make sure that the division does not fail to compile fn average(values: &[f64]) -> f64 { let total = values .iter() .fold(0.0, |a, b| a + b); total / (values.len() as f64) -======= -// I AM NOT DONE - -fn average(values: &[f64]) -> f64 { - let total = values.iter().sum::(); - total / values.len() ->>>>>>> 11d8aea96f2c744d970ed1ffb38785cf5b511e5e } fn main() { diff --git a/exercises/enums/enums3.rs b/exercises/enums/enums3.rs index cd39e670..eb4ffaf9 100644 --- a/exercises/enums/enums3.rs +++ b/exercises/enums/enums3.rs @@ -41,7 +41,6 @@ impl State { } fn process(&mut self, message: Message) { -<<<<<<< HEAD // TODO: create a match expression to process the different message variants match message { Message::ChangeColor(r, g, b) => self.change_color((r, g, b)), @@ -52,12 +51,6 @@ impl State { }, _ => self.quit(), } -======= - // TODO: create a match expression to process the different message - // variants - // Remember: When passing a tuple as a function argument, you'll need - // extra parentheses: fn function((t, u, p, l, e)) ->>>>>>> 11d8aea96f2c744d970ed1ffb38785cf5b511e5e } } @@ -75,11 +68,7 @@ mod tests { }; state.process(Message::ChangeColor(255, 0, 255)); state.process(Message::Echo(String::from("hello world"))); -<<<<<<< HEAD state.process(Message::Move{ x: 10, y: 15 }); -======= - state.process(Message::Move(Point { x: 10, y: 15 })); ->>>>>>> 11d8aea96f2c744d970ed1ffb38785cf5b511e5e state.process(Message::Quit); assert_eq!(state.color, (255, 0, 255)); diff --git a/exercises/error_handling/errors1.rs b/exercises/error_handling/errors1.rs index 0e027dce..e64ef7d4 100644 --- a/exercises/error_handling/errors1.rs +++ b/exercises/error_handling/errors1.rs @@ -9,23 +9,12 @@ // Execute `rustlings hint errors1` or use the `hint` watch subcommand for a // hint. -<<<<<<< HEAD pub fn generate_nametag_text(name: String) -> Result { if name.len() > 0 { Ok(format!("Hi! My name is {}", name)) } else { // Empty names aren't allowed. Err("`name` was empty; it must be nonempty.".into()) -======= -// I AM NOT DONE - -pub fn generate_nametag_text(name: String) -> Option { - if name.is_empty() { - // Empty names aren't allowed. - None - } else { - Some(format!("Hi! My name is {}", name)) ->>>>>>> 11d8aea96f2c744d970ed1ffb38785cf5b511e5e } } diff --git a/exercises/error_handling/errors4.rs b/exercises/error_handling/errors4.rs index cb69a693..6f003f05 100644 --- a/exercises/error_handling/errors4.rs +++ b/exercises/error_handling/errors4.rs @@ -14,7 +14,6 @@ enum CreationError { impl PositiveNonzeroInteger { fn new(value: i64) -> Result { -<<<<<<< HEAD:exercises/error_handling/result1.rs if value > 1 { Ok(PositiveNonzeroInteger(value as u64)) } else if value == 0 { @@ -23,10 +22,6 @@ impl PositiveNonzeroInteger { Err(CreationError::Negative) } -======= - // Hmm... Why is this always returning an Ok value? - Ok(PositiveNonzeroInteger(value as u64)) ->>>>>>> 11d8aea96f2c744d970ed1ffb38785cf5b511e5e:exercises/error_handling/errors4.rs } } diff --git a/exercises/functions/functions2.rs b/exercises/functions/functions2.rs index 6d0a20e9..92dac557 100644 --- a/exercises/functions/functions2.rs +++ b/exercises/functions/functions2.rs @@ -1,23 +1,11 @@ // functions2.rs -<<<<<<< HEAD // Make me compile! Execute `rustlings hint functions2` for hints :)s -======= -// -// Execute `rustlings hint functions2` or use the `hint` watch subcommand for a -// hint. - -// I AM NOT DONE ->>>>>>> 11d8aea96f2c744d970ed1ffb38785cf5b511e5e fn main() { call_me(3); } -<<<<<<< HEAD fn call_me(num: i32) { -======= -fn call_me(num:) { ->>>>>>> 11d8aea96f2c744d970ed1ffb38785cf5b511e5e for i in 0..num { println!("Ring! Call number {}", i + 1); } diff --git a/exercises/generics/generics2.rs b/exercises/generics/generics2.rs index 6f7a2612..c2f5a30e 100644 --- a/exercises/generics/generics2.rs +++ b/exercises/generics/generics2.rs @@ -6,17 +6,9 @@ // Execute `rustlings hint generics2` or use the `hint` watch subcommand for a // hint. -<<<<<<< HEAD struct Wrapper { value: T } -======= -// I AM NOT DONE - -struct Wrapper { - value: u32, -} ->>>>>>> 11d8aea96f2c744d970ed1ffb38785cf5b511e5e impl Wrapper { pub fn new(value: T) -> Self { diff --git a/exercises/if/if1.rs b/exercises/if/if1.rs index 0999ae5c..47e13e69 100644 --- a/exercises/if/if1.rs +++ b/exercises/if/if1.rs @@ -7,15 +7,12 @@ pub fn bigger(a: i32, b: i32) -> i32 { // Do not use: // - another function call // - additional variables -<<<<<<< HEAD // Execute `rustlings hint if1` for hints if (a > b) { return a; } else { return b; } -======= ->>>>>>> 11d8aea96f2c744d970ed1ffb38785cf5b511e5e } // Don't mind this for now :) diff --git a/exercises/if/if2.rs b/exercises/if/if2.rs index 0f1d0e72..5b33753a 100644 --- a/exercises/if/if2.rs +++ b/exercises/if/if2.rs @@ -5,13 +5,7 @@ // // Execute `rustlings hint if2` or use the `hint` watch subcommand for a hint. -<<<<<<< HEAD pub fn fizz_if_foo(fizzish: &str) -> &str { -======= -// I AM NOT DONE - -pub fn foo_if_fizz(fizzish: &str) -> &str { ->>>>>>> 11d8aea96f2c744d970ed1ffb38785cf5b511e5e if fizzish == "fizz" { "foo" } else if fizzish == "fuzz" { diff --git a/exercises/macros/macros4.rs b/exercises/macros/macros4.rs index e1faab43..5f1ed7e8 100644 --- a/exercises/macros/macros4.rs +++ b/exercises/macros/macros4.rs @@ -3,12 +3,6 @@ // Execute `rustlings hint macros4` or use the `hint` watch subcommand for a // hint. -<<<<<<< HEAD -======= -// I AM NOT DONE - -#[rustfmt::skip] ->>>>>>> 11d8aea96f2c744d970ed1ffb38785cf5b511e5e macro_rules! my_macro { () => { println!("Check out my macro!"); diff --git a/exercises/modules/modules1.rs b/exercises/modules/modules1.rs index 7365abb9..7f2196f1 100644 --- a/exercises/modules/modules1.rs +++ b/exercises/modules/modules1.rs @@ -4,17 +4,7 @@ // hint. mod sausage_factory { -<<<<<<< HEAD pub fn make_sausage() { -======= - // Don't let anybody outside of this module see this! - fn get_secret_recipe() -> String { - String::from("Ginger") - } - - fn make_sausage() { - get_secret_recipe(); ->>>>>>> 11d8aea96f2c744d970ed1ffb38785cf5b511e5e println!("sausage!"); } } diff --git a/exercises/modules/modules2.rs b/exercises/modules/modules2.rs index eb8e2581..ad8ecd33 100644 --- a/exercises/modules/modules2.rs +++ b/exercises/modules/modules2.rs @@ -8,14 +8,8 @@ // hint. mod delicious_snacks { -<<<<<<< HEAD pub use self::fruits::PEAR as fruit; pub use self::veggies::CUCUMBER as veggie; -======= - // TODO: Fix these use statements - use self::fruits::PEAR as ??? - use self::veggies::CUCUMBER as ??? ->>>>>>> 11d8aea96f2c744d970ed1ffb38785cf5b511e5e mod fruits { pub const PEAR: &'static str = "Pear"; diff --git a/exercises/primitive_types/primitive_types2.rs b/exercises/primitive_types/primitive_types2.rs index 97693376..1323ae30 100644 --- a/exercises/primitive_types/primitive_types2.rs +++ b/exercises/primitive_types/primitive_types2.rs @@ -9,13 +9,7 @@ fn main() { // Characters (`char`) -<<<<<<< HEAD let my_first_initial: char = 'C'; -======= - // Note the _single_ quotes, these are different from the double quotes - // you've been seeing around. - let my_first_initial = 'C'; ->>>>>>> 11d8aea96f2c744d970ed1ffb38785cf5b511e5e if my_first_initial.is_alphabetic() { println!("Alphabetical!"); } else if my_first_initial.is_numeric() { diff --git a/exercises/primitive_types/primitive_types6.rs b/exercises/primitive_types/primitive_types6.rs index 583394d9..8b46312f 100644 --- a/exercises/primitive_types/primitive_types6.rs +++ b/exercises/primitive_types/primitive_types6.rs @@ -6,20 +6,7 @@ // Execute `rustlings hint primitive_types6` or use the `hint` watch subcommand // for a hint. -<<<<<<< HEAD fn main() { let numbers = (1, 2, 3); println!("The second number is {}", numbers.1); -======= -// I AM NOT DONE - -#[test] -fn indexing_tuple() { - let numbers = (1, 2, 3); - // Replace below ??? with the tuple indexing syntax. - let second = ???; - - assert_eq!(2, second, - "This is not the 2nd number in the tuple!") ->>>>>>> 11d8aea96f2c744d970ed1ffb38785cf5b511e5e } diff --git a/exercises/quiz3.rs b/exercises/quiz3.rs index 1e5f3439..15abd10a 100644 --- a/exercises/quiz3.rs +++ b/exercises/quiz3.rs @@ -16,24 +16,8 @@ // // Execute `rustlings hint quiz3` or use the `hint` watch subcommand for a hint. -<<<<<<< HEAD pub fn times_two(num: i32) -> i32 { num * 2 -======= -// I AM NOT DONE - -pub struct ReportCard { - pub grade: f32, - pub student_name: String, - pub student_age: u8, -} - -impl ReportCard { - pub fn print(&self) -> String { - format!("{} ({}) - achieved a grade of {}", - &self.student_name, &self.student_age, &self.grade) - } ->>>>>>> 11d8aea96f2c744d970ed1ffb38785cf5b511e5e } #[cfg(test)] @@ -41,7 +25,6 @@ mod tests { use super::*; #[test] -<<<<<<< HEAD fn returns_twice_of_positive_numbers() { assert_eq!(times_two(4), 8); } @@ -50,31 +33,5 @@ mod tests { fn returns_twice_of_negative_numbers() { // TODO write an assert for `times_two(-4)` assert_eq!(times_two(-4), -8); -======= - fn generate_numeric_report_card() { - let report_card = ReportCard { - grade: 2.1, - student_name: "Tom Wriggle".to_string(), - student_age: 12, - }; - assert_eq!( - report_card.print(), - "Tom Wriggle (12) - achieved a grade of 2.1" - ); - } - - #[test] - fn generate_alphabetic_report_card() { - // TODO: Make sure to change the grade here after you finish the exercise. - let report_card = ReportCard { - grade: 2.1, - student_name: "Gary Plotter".to_string(), - student_age: 11, - }; - assert_eq!( - report_card.print(), - "Gary Plotter (11) - achieved a grade of A+" - ); ->>>>>>> 11d8aea96f2c744d970ed1ffb38785cf5b511e5e } } diff --git a/exercises/smart_pointers/box1.rs b/exercises/smart_pointers/box1.rs index 0ecc628f..71733f61 100644 --- a/exercises/smart_pointers/box1.rs +++ b/exercises/smart_pointers/box1.rs @@ -33,19 +33,11 @@ fn main() { } pub fn create_empty_list() -> List { -<<<<<<< HEAD:exercises/standard_library_types/box1.rs List::Nil } pub fn create_non_empty_list() -> List { List::Cons(1, Box::new(List::Nil)) -======= - todo!() -} - -pub fn create_non_empty_list() -> List { - todo!() ->>>>>>> 11d8aea96f2c744d970ed1ffb38785cf5b511e5e:exercises/smart_pointers/box1.rs } #[cfg(test)] diff --git a/exercises/structs/structs1.rs b/exercises/structs/structs1.rs index e1801694..7a03f209 100644 --- a/exercises/structs/structs1.rs +++ b/exercises/structs/structs1.rs @@ -45,15 +45,9 @@ mod tests { #[test] fn unit_structs() { -<<<<<<< HEAD // TODO: Instantiate a unit struct! let unit_struct = UnitStruct; let message = format!("{:?}s are fun!", unit_struct); -======= - // TODO: Instantiate a unit-like struct! - // let unit_like_struct = - let message = format!("{:?}s are fun!", unit_like_struct); ->>>>>>> 11d8aea96f2c744d970ed1ffb38785cf5b511e5e assert_eq!(message, "UnitLikeStructs are fun!"); } diff --git a/exercises/structs/structs3.rs b/exercises/structs/structs3.rs index 7bdd1717..80fe2b4d 100644 --- a/exercises/structs/structs3.rs +++ b/exercises/structs/structs3.rs @@ -17,12 +17,8 @@ struct Package { impl Package { fn new(sender_country: String, recipient_country: String, weight_in_grams: i32) -> Package { if weight_in_grams <= 0 { -<<<<<<< HEAD // Something goes here... panic!("Package is lighter then air!") -======= - panic!("Can not ship a weightless package.") ->>>>>>> 11d8aea96f2c744d970ed1ffb38785cf5b511e5e } else { Package { sender_country, @@ -37,14 +33,9 @@ impl Package { self.recipient_country != self.sender_country } -<<<<<<< HEAD fn get_fees(&self, cents_per_kg: i32) -> i32 { // Something goes here... (beware of grams to kg conversion) (self.weight_in_grams * cents_per_kg) / 100 -======= - fn get_fees(&self, cents_per_gram: i32) -> ??? { - // Something goes here... ->>>>>>> 11d8aea96f2c744d970ed1ffb38785cf5b511e5e } } @@ -86,13 +77,8 @@ mod tests { let sender_country = String::from("Spain"); let recipient_country = String::from("Spain"); -<<<<<<< HEAD let cents_per_kg = 300; -======= - let cents_per_gram = 3; - ->>>>>>> 11d8aea96f2c744d970ed1ffb38785cf5b511e5e let package = Package::new(sender_country, recipient_country, 1500); assert_eq!(package.get_fees(cents_per_gram), 4500); diff --git a/exercises/threads/threads1.rs b/exercises/threads/threads1.rs index 20f36cc4..ea95e9ec 100644 --- a/exercises/threads/threads1.rs +++ b/exercises/threads/threads1.rs @@ -8,17 +8,11 @@ // Execute `rustlings hint threads1` or use the `hint` watch subcommand for a // hint. -<<<<<<< HEAD use std::sync::{Arc, Mutex}; -======= -// I AM NOT DONE - ->>>>>>> 11d8aea96f2c744d970ed1ffb38785cf5b511e5e use std::thread; use std::time::{Duration, Instant}; fn main() { -<<<<<<< HEAD // Introduce Mutex let status = Arc::new(Mutex::new(JobStatus { jobs_completed: 0 })); let status_shared = status.clone(); @@ -34,29 +28,5 @@ fn main() { while status.lock().unwrap().jobs_completed < 10 { println!("waiting... "); thread::sleep(Duration::from_millis(500)); -======= - let mut handles = vec![]; - for i in 0..10 { - handles.push(thread::spawn(move || { - let start = Instant::now(); - thread::sleep(Duration::from_millis(250)); - println!("thread {} is complete", i); - start.elapsed().as_millis() - })); - } - - let mut results: Vec = vec![]; - for handle in handles { - // TODO: a struct is returned from thread::spawn, can you use it? - } - - if results.len() != 10 { - panic!("Oh no! All the spawned threads did not finish!"); - } - - println!(); - for (i, result) in results.into_iter().enumerate() { - println!("thread {} took {}ms", i, result); ->>>>>>> 11d8aea96f2c744d970ed1ffb38785cf5b511e5e } } diff --git a/exercises/traits/traits1.rs b/exercises/traits/traits1.rs index 6e00cce9..4ea8c36c 100644 --- a/exercises/traits/traits1.rs +++ b/exercises/traits/traits1.rs @@ -7,23 +7,14 @@ // Execute `rustlings hint traits1` or use the `hint` watch subcommand for a // hint. -<<<<<<< HEAD -======= -// I AM NOT DONE - ->>>>>>> 11d8aea96f2c744d970ed1ffb38785cf5b511e5e trait AppendBar { fn append_bar(self) -> Self; } impl AppendBar for String { -<<<<<<< HEAD fn append_bar(self) -> Self { self + "Bar" } -======= - // TODO: Implement `AppendBar` for type `String`. ->>>>>>> 11d8aea96f2c744d970ed1ffb38785cf5b511e5e } fn main() { diff --git a/exercises/traits/traits2.rs b/exercises/traits/traits2.rs index f9e19186..eafc2a3e 100644 --- a/exercises/traits/traits2.rs +++ b/exercises/traits/traits2.rs @@ -12,16 +12,12 @@ trait AppendBar { fn append_bar(self) -> Self; } -<<<<<<< HEAD impl AppendBar for Vec { fn append_bar(mut self) -> Self { self.push(String::from("Bar")); self } } -======= -// TODO: Implement trait `AppendBar` for a vector of strings. ->>>>>>> 11d8aea96f2c744d970ed1ffb38785cf5b511e5e #[cfg(test)] mod tests { diff --git a/exercises/variables/variables3.rs b/exercises/variables/variables3.rs index aecbbc5f..eade4734 100644 --- a/exercises/variables/variables3.rs +++ b/exercises/variables/variables3.rs @@ -4,12 +4,8 @@ // hint. fn main() { -<<<<<<< HEAD let mut x = 3; println!("Number {}", x); x = 5; // don't change this line -======= - let x: i32; ->>>>>>> 11d8aea96f2c744d970ed1ffb38785cf5b511e5e println!("Number {}", x); } diff --git a/exercises/variables/variables4.rs b/exercises/variables/variables4.rs index 7da4a366..45434bc7 100644 --- a/exercises/variables/variables4.rs +++ b/exercises/variables/variables4.rs @@ -4,12 +4,6 @@ // hint. fn main() { -<<<<<<< HEAD let x: i32 = 256 * 256 * 256; -======= - let x = 3; - println!("Number {}", x); - x = 5; // don't change this line ->>>>>>> 11d8aea96f2c744d970ed1ffb38785cf5b511e5e println!("Number {}", x); } diff --git a/exercises/variables/variables5.rs b/exercises/variables/variables5.rs index df745076..85281244 100644 --- a/exercises/variables/variables5.rs +++ b/exercises/variables/variables5.rs @@ -4,15 +4,8 @@ // hint. fn main() { -<<<<<<< HEAD let number = "3"; // don't change this line println!("Number {}", number); let number = 3; println!("Number {}", number); -======= - let number = "T-H-R-E-E"; // don't change this line - println!("Spell a Number : {}", number); - number = 3; // don't rename this variable - println!("Number plus two is : {}", number + 2); ->>>>>>> 11d8aea96f2c744d970ed1ffb38785cf5b511e5e }