diff options
Diffstat (limited to 'exercises')
51 files changed, 107 insertions, 0 deletions
diff --git a/exercises/enums/enums1.rs b/exercises/enums/enums1.rs index 8b14f29..f490928 100644 --- a/exercises/enums/enums1.rs +++ b/exercises/enums/enums1.rs @@ -1,6 +1,8 @@ // enums1.rs // Make me compile! Scroll down for hints! +// I AM NOT DONE + #[derive(Debug)] enum Message { // TODO: define a few types of messages as used below diff --git a/exercises/enums/enums2.rs b/exercises/enums/enums2.rs index 71ac839..8f04bd8 100644 --- a/exercises/enums/enums2.rs +++ b/exercises/enums/enums2.rs @@ -1,6 +1,8 @@ // enums2.rs // Make me compile! Scroll down for hints +// I AM NOT DONE + #[derive(Debug)] enum Message { // TODO: define the different variants used below diff --git a/exercises/enums/enums3.rs b/exercises/enums/enums3.rs index c5d81bf..bb7dfb4 100644 --- a/exercises/enums/enums3.rs +++ b/exercises/enums/enums3.rs @@ -1,6 +1,8 @@ // enums3.rs // Address all the TODOs to make the tests pass! +// I AM NOT DONE + enum Message { // TODO: implement the message variant types based on their usage below } diff --git a/exercises/error_handling/errors1.rs b/exercises/error_handling/errors1.rs index 8483234..a06f0ca 100644 --- a/exercises/error_handling/errors1.rs +++ b/exercises/error_handling/errors1.rs @@ -6,6 +6,8 @@ // this function to have. // Scroll down for hints!!! +// I AM NOT DONE + pub fn generate_nametag_text(name: String) -> Option<String> { if name.len() > 0 { Some(format!("Hi! My name is {}", name)) diff --git a/exercises/error_handling/errors2.rs b/exercises/error_handling/errors2.rs index 8b81207..315528f 100644 --- a/exercises/error_handling/errors2.rs +++ b/exercises/error_handling/errors2.rs @@ -16,6 +16,8 @@ // There are at least two ways to implement this that are both correct-- but // one is a lot shorter! Scroll down for hints to both ways. +// I AM NOT DONE + use std::num::ParseIntError; pub fn total_cost(item_quantity: &str) -> Result<i32, ParseIntError> { diff --git a/exercises/error_handling/errors3.rs b/exercises/error_handling/errors3.rs index 31800fc..35cd5c3 100644 --- a/exercises/error_handling/errors3.rs +++ b/exercises/error_handling/errors3.rs @@ -3,6 +3,8 @@ // `total_cost` function from the previous exercise. It's not working though! // Why not? What should we do to fix it? Scroll for hints! +// I AM NOT DONE + use std::num::ParseIntError; fn main() { diff --git a/exercises/error_handling/errorsn.rs b/exercises/error_handling/errorsn.rs index c2b16ce..cc90801 100644 --- a/exercises/error_handling/errorsn.rs +++ b/exercises/error_handling/errorsn.rs @@ -15,6 +15,8 @@ // // Scroll down for hints :) +// I AM NOT DONE + use std::error; use std::fmt; use std::io; diff --git a/exercises/error_handling/option1.rs b/exercises/error_handling/option1.rs index c5a4a64..4e432a6 100644 --- a/exercises/error_handling/option1.rs +++ b/exercises/error_handling/option1.rs @@ -4,6 +4,8 @@ // on `None`. Handle this in a more graceful way than calling `unwrap`! // Scroll down for hints :) +// I AM NOT DONE + pub fn pop_too_much() -> bool { let mut list = vec![3]; diff --git a/exercises/error_handling/result1.rs b/exercises/error_handling/result1.rs index f9596e2..52972dc 100644 --- a/exercises/error_handling/result1.rs +++ b/exercises/error_handling/result1.rs @@ -1,6 +1,8 @@ // result1.rs // Make this test pass! Scroll down for hints :) +// I AM NOT DONE + #[derive(PartialEq, Debug)] struct PositiveNonzeroInteger(u64); diff --git a/exercises/functions/functions1.rs b/exercises/functions/functions1.rs index 396dd56..b9312ae 100644 --- a/exercises/functions/functions1.rs +++ b/exercises/functions/functions1.rs @@ -1,6 +1,8 @@ // functions1.rs // Make me compile! Scroll down for hints :) +// I AM NOT DONE + fn main() { call_me(); } diff --git a/exercises/functions/functions2.rs b/exercises/functions/functions2.rs index 1cf95c3..c5b4418 100644 --- a/exercises/functions/functions2.rs +++ b/exercises/functions/functions2.rs @@ -1,6 +1,8 @@ // functions2.rs // Make me compile! Scroll down for hints :) +// I AM NOT DONE + fn main() { call_me(3); } diff --git a/exercises/functions/functions3.rs b/exercises/functions/functions3.rs index b17543b..63bb586 100644 --- a/exercises/functions/functions3.rs +++ b/exercises/functions/functions3.rs @@ -1,6 +1,8 @@ // functions3.rs // Make me compile! Scroll down for hints :) +// I AM NOT DONE + fn main() { call_me(); } diff --git a/exercises/functions/functions4.rs b/exercises/functions/functions4.rs index 5baca0e..91f6295 100644 --- a/exercises/functions/functions4.rs +++ b/exercises/functions/functions4.rs @@ -4,6 +4,8 @@ // This store is having a sale where if the price is an even number, you get // 10 (money unit) off, but if it's an odd number, it's 3 (money unit) less. +// I AM NOT DONE + fn main() { let original_price = 51; println!("Your sale price is {}", sale_price(original_price)); diff --git a/exercises/functions/functions5.rs b/exercises/functions/functions5.rs index d9227c9..696edee 100644 --- a/exercises/functions/functions5.rs +++ b/exercises/functions/functions5.rs @@ -1,6 +1,8 @@ // functions5.rs // Make me compile! Scroll down for hints :) +// I AM NOT DONE + fn main() { let answer = square(3); println!("The answer is {}", answer); diff --git a/exercises/if/if1.rs b/exercises/if/if1.rs index 6da09d3..da77e35 100644 --- a/exercises/if/if1.rs +++ b/exercises/if/if1.rs @@ -1,5 +1,7 @@ // if1.rs +// I AM NOT DONE + pub fn bigger(a: i32, b: i32) -> i32 { // Complete this function to return the bigger number! // Do not use: diff --git a/exercises/macros/macros1.rs b/exercises/macros/macros1.rs index a7c78a5..f7b89e0 100644 --- a/exercises/macros/macros1.rs +++ b/exercises/macros/macros1.rs @@ -1,6 +1,8 @@ // macros1.rs // Make me compile! Scroll down for hints :) +// I AM NOT DONE + macro_rules! my_macro { () => { println!("Check out my macro!"); diff --git a/exercises/macros/macros2.rs b/exercises/macros/macros2.rs index bc2e56b..7fe9429 100644 --- a/exercises/macros/macros2.rs +++ b/exercises/macros/macros2.rs @@ -1,6 +1,8 @@ // macros2.rs // Make me compile! Scroll down for hints :) +// I AM NOT DONE + fn main() { my_macro!(); } diff --git a/exercises/macros/macros3.rs b/exercises/macros/macros3.rs index 84c4308..e9ef7f3 100644 --- a/exercises/macros/macros3.rs +++ b/exercises/macros/macros3.rs @@ -1,6 +1,8 @@ // macros3.rs // Make me compile, without taking the macro out of the module! Scroll down for hints :) +// I AM NOT DONE + mod macros { macro_rules! my_macro { () => { diff --git a/exercises/macros/macros4.rs b/exercises/macros/macros4.rs index d844bb0..2893a15 100644 --- a/exercises/macros/macros4.rs +++ b/exercises/macros/macros4.rs @@ -1,6 +1,8 @@ // macros4.rs // Make me compile! Scroll down for hints :) +// I AM NOT DONE + macro_rules! my_macro { () => { println!("Check out my macro!"); diff --git a/exercises/modules/modules1.rs b/exercises/modules/modules1.rs index 0e092c5..3f44968 100644 --- a/exercises/modules/modules1.rs +++ b/exercises/modules/modules1.rs @@ -1,6 +1,8 @@ // modules1.rs // Make me compile! Scroll down for hints :) +// I AM NOT DONE + mod sausage_factory { fn make_sausage() { println!("sausage!"); diff --git a/exercises/modules/modules2.rs b/exercises/modules/modules2.rs index 3cfa36d..a3497cf 100644 --- a/exercises/modules/modules2.rs +++ b/exercises/modules/modules2.rs @@ -1,6 +1,8 @@ // modules2.rs // Make me compile! Scroll down for hints :) +// I AM NOT DONE + mod delicious_snacks { use self::fruits::PEAR as fruit; use self::veggies::CUCUMBER as veggie; diff --git a/exercises/move_semantics/move_semantics1.rs b/exercises/move_semantics/move_semantics1.rs index ab855fc..625096d 100644 --- a/exercises/move_semantics/move_semantics1.rs +++ b/exercises/move_semantics/move_semantics1.rs @@ -1,6 +1,8 @@ // move_semantics1.rs // Make me compile! Scroll down for hints :) +// I AM NOT DONE + fn main() { let vec0 = Vec::new(); diff --git a/exercises/move_semantics/move_semantics2.rs b/exercises/move_semantics/move_semantics2.rs index f85b3ed..28749e2 100644 --- a/exercises/move_semantics/move_semantics2.rs +++ b/exercises/move_semantics/move_semantics2.rs @@ -1,6 +1,8 @@ // move_semantics2.rs // Make me compile without changing line 10! Scroll down for hints :) +// I AM NOT DONE + fn main() { let vec0 = Vec::new(); diff --git a/exercises/move_semantics/move_semantics3.rs b/exercises/move_semantics/move_semantics3.rs index 8b91896..a5b41b4 100644 --- a/exercises/move_semantics/move_semantics3.rs +++ b/exercises/move_semantics/move_semantics3.rs @@ -3,6 +3,8 @@ // (no lines with multiple semicolons necessary!) // Scroll down for hints :) +// I AM NOT DONE + fn main() { let vec0 = Vec::new(); diff --git a/exercises/move_semantics/move_semantics4.rs b/exercises/move_semantics/move_semantics4.rs index 90930f0..b01e593 100644 --- a/exercises/move_semantics/move_semantics4.rs +++ b/exercises/move_semantics/move_semantics4.rs @@ -3,6 +3,8 @@ // in `fn main`, we instead create it within `fn fill_vec` and transfer the // freshly created vector from fill_vec to its caller. Scroll for hints! +// I AM NOT DONE + fn main() { let vec0 = Vec::new(); diff --git a/exercises/primitive_types/primitive_types1.rs b/exercises/primitive_types/primitive_types1.rs index c3d11fe..0912139 100644 --- a/exercises/primitive_types/primitive_types1.rs +++ b/exercises/primitive_types/primitive_types1.rs @@ -2,6 +2,8 @@ // Fill in the rest of the line that has code missing! // No hints, there's no tricks, just get used to typing these :) +// I AM NOT DONE + fn main() { // Booleans (`bool`) diff --git a/exercises/primitive_types/primitive_types2.rs b/exercises/primitive_types/primitive_types2.rs index f5c8f87..6576a4d 100644 --- a/exercises/primitive_types/primitive_types2.rs +++ b/exercises/primitive_types/primitive_types2.rs @@ -2,6 +2,8 @@ // Fill in the rest of the line that has code missing! // No hints, there's no tricks, just get used to typing these :) +// I AM NOT DONE + fn main() { // Characters (`char`) diff --git a/exercises/primitive_types/primitive_types3.rs b/exercises/primitive_types/primitive_types3.rs index 7ce2226..bf2716a 100644 --- a/exercises/primitive_types/primitive_types3.rs +++ b/exercises/primitive_types/primitive_types3.rs @@ -2,6 +2,8 @@ // Create an array with at least 100 elements in it where the ??? is. // Scroll down for hints! +// I AM NOT DONE + fn main() { let a = ??? diff --git a/exercises/primitive_types/primitive_types4.rs b/exercises/primitive_types/primitive_types4.rs index e1ccdbc..e675aa1 100644 --- a/exercises/primitive_types/primitive_types4.rs +++ b/exercises/primitive_types/primitive_types4.rs @@ -2,6 +2,8 @@ // Get a slice out of Array a where the ??? is so that the `if` statement // returns true. Scroll down for hints!! +// I AM NOT DONE + #[test] fn main() { let a = [1, 2, 3, 4, 5]; diff --git a/exercises/primitive_types/primitive_types5.rs b/exercises/primitive_types/primitive_types5.rs index 0d53c9c..d8527ee 100644 --- a/exercises/primitive_types/primitive_types5.rs +++ b/exercises/primitive_types/primitive_types5.rs @@ -2,6 +2,8 @@ // Destructure the `cat` tuple so that the println will work. // Scroll down for hints! +// I AM NOT DONE + fn main() { let cat = ("Furry McFurson", 3.5); let /* your pattern here */ = cat; diff --git a/exercises/primitive_types/primitive_types6.rs b/exercises/primitive_types/primitive_types6.rs index 854544f..8fe9a36 100644 --- a/exercises/primitive_types/primitive_types6.rs +++ b/exercises/primitive_types/primitive_types6.rs @@ -3,6 +3,8 @@ // You can put this right into the `println!` where the ??? is. // Scroll down for hints! +// I AM NOT DONE + fn main() { let numbers = (1, 2, 3); println!("The second number is {}", ???); diff --git a/exercises/standard_library_types/arc1.rs b/exercises/standard_library_types/arc1.rs index d610e5f..effd28a 100644 --- a/exercises/standard_library_types/arc1.rs +++ b/exercises/standard_library_types/arc1.rs @@ -4,6 +4,8 @@ // somewhere. Try not to create any copies of the `numbers` Vec! // Scroll down for hints :) +// I AM NOT DONE + use std::sync::Arc; use std::thread; diff --git a/exercises/standard_library_types/iterators2.rs b/exercises/standard_library_types/iterators2.rs index b6d3366..ea523e7 100644 --- a/exercises/standard_library_types/iterators2.rs +++ b/exercises/standard_library_types/iterators2.rs @@ -5,6 +5,8 @@ // Step 3. Apply the `capitalize_first` function again to a list, but try and ensure it returns a single string // As always, there are hints below! +// I AM NOT DONE + pub fn capitalize_first(input: &str) -> String { let mut c = input.chars(); match c.next() { diff --git a/exercises/standard_library_types/iterators3.rs b/exercises/standard_library_types/iterators3.rs index c012795..8fc57f2 100644 --- a/exercises/standard_library_types/iterators3.rs +++ b/exercises/standard_library_types/iterators3.rs @@ -8,6 +8,8 @@ // a major hint. // Have fun :-) +// I AM NOT DONE + #[derive(Debug, PartialEq, Eq)] pub enum DivisionError { NotDivisible(NotDivisibleError), diff --git a/exercises/standard_library_types/iterators4.rs b/exercises/standard_library_types/iterators4.rs index 13613a6..39be8bf 100644 --- a/exercises/standard_library_types/iterators4.rs +++ b/exercises/standard_library_types/iterators4.rs @@ -1,5 +1,7 @@ // iterators4.rs +// I AM NOT DONE + pub fn factorial(num: u64) -> u64 { // Complete this function to return factorial of num // Do not use: diff --git a/exercises/strings/strings1.rs b/exercises/strings/strings1.rs index 2e5088f..3335734 100644 --- a/exercises/strings/strings1.rs +++ b/exercises/strings/strings1.rs @@ -1,6 +1,8 @@ // strings1.rs // Make me compile without changing the function signature! Scroll down for hints :) +// I AM NOT DONE + fn main() { let answer = current_favorite_color(); println!("My current favorite color is {}", answer); diff --git a/exercises/strings/strings2.rs b/exercises/strings/strings2.rs index c77e16f..3890cfe 100644 --- a/exercises/strings/strings2.rs +++ b/exercises/strings/strings2.rs @@ -1,6 +1,8 @@ // strings2.rs // Make me compile without changing the function signature! Scroll down for hints :) +// I AM NOT DONE + fn main() { let word = String::from("green"); // Try not changing this line :) if is_a_color_word(word) { diff --git a/exercises/structs/structs1.rs b/exercises/structs/structs1.rs index 138b3fd..6d0b2f4 100644 --- a/exercises/structs/structs1.rs +++ b/exercises/structs/structs1.rs @@ -1,6 +1,8 @@ // structs1.rs // Address all the TODOs to make the tests pass! +// I AM NOT DONE + struct ColorClassicStruct { // TODO: Something goes here } diff --git a/exercises/structs/structs2.rs b/exercises/structs/structs2.rs index db381e7..0699137 100644 --- a/exercises/structs/structs2.rs +++ b/exercises/structs/structs2.rs @@ -2,6 +2,8 @@ // Address all the TODOs to make the tests pass! // No hints, just do it! +// I AM NOT DONE + #[derive(Debug)] struct Order { name: String, diff --git a/exercises/test1.rs b/exercises/test1.rs index 6c27355..3e13ce5 100644 --- a/exercises/test1.rs +++ b/exercises/test1.rs @@ -7,6 +7,8 @@ // more than 40 at once, each apple only costs 1! Write a function that calculates // the price of an order of apples given the order amount. No hints this time! +// I AM NOT DONE + // Put your function here! // fn ..... { diff --git a/exercises/test2.rs b/exercises/test2.rs index 7fe81c6..d01606c 100644 --- a/exercises/test2.rs +++ b/exercises/test2.rs @@ -7,6 +7,8 @@ // you think each value is. That is, add either `string_slice` or `string` // before the parentheses on each line. If you're right, it will compile! +// I AM NOT DONE + fn string_slice(arg: &str) { println!("{}", arg); } diff --git a/exercises/test3.rs b/exercises/test3.rs index 9a72118..f94c36f 100644 --- a/exercises/test3.rs +++ b/exercises/test3.rs @@ -7,6 +7,8 @@ // we expect to get when we call `times_two` with a negative number. // No hints, you can do this :) +// I AM NOT DONE + pub fn times_two(num: i32) -> i32 { num * 2 } diff --git a/exercises/test4.rs b/exercises/test4.rs index e50f1b0..c543a64 100644 --- a/exercises/test4.rs +++ b/exercises/test4.rs @@ -5,6 +5,8 @@ // Write a macro that passes the test! No hints this time, you can do it! +// I AM NOT DONE + fn main() { if my_macro!("world!") != "Hello world!" { panic!("Oh no! Wrong output!"); diff --git a/exercises/tests/tests1.rs b/exercises/tests/tests1.rs index b11221f..1465e37 100644 --- a/exercises/tests/tests1.rs +++ b/exercises/tests/tests1.rs @@ -6,6 +6,8 @@ // This test has a problem with it -- make the test compile! Make the test // pass! Make the test fail! Scroll down for hints :) +// I AM NOT DONE + #[cfg(test)] mod tests { #[test] diff --git a/exercises/tests/tests2.rs b/exercises/tests/tests2.rs index 6775d61..81e30e0 100644 --- a/exercises/tests/tests2.rs +++ b/exercises/tests/tests2.rs @@ -2,6 +2,8 @@ // This test has a problem with it -- make the test compile! Make the test // pass! Make the test fail! Scroll down for hints :) +// I AM NOT DONE + #[cfg(test)] mod tests { #[test] diff --git a/exercises/tests/tests3.rs b/exercises/tests/tests3.rs index e10d2aa..af48095 100644 --- a/exercises/tests/tests3.rs +++ b/exercises/tests/tests3.rs @@ -3,6 +3,8 @@ // 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)`. Scroll down for hints! +// I AM NOT DONE + pub fn is_even(num: i32) -> bool { num % 2 == 0 } diff --git a/exercises/threads/threads1.rs b/exercises/threads/threads1.rs index 7983668..d23553e 100644 --- a/exercises/threads/threads1.rs +++ b/exercises/threads/threads1.rs @@ -5,6 +5,8 @@ // of "waiting..." and the program ends without timing out the playground, // you've got it :) +// I AM NOT DONE + use std::sync::Arc; use std::thread; use std::time::Duration; diff --git a/exercises/variables/variables1.rs b/exercises/variables/variables1.rs index 1cdd270..174ad80 100644 --- a/exercises/variables/variables1.rs +++ b/exercises/variables/variables1.rs @@ -1,6 +1,13 @@ // variables1.rs // Make me compile! Scroll down for hints :) +// About this `I AM NOT DONE` thing: +// We sometimes encourage you to keep trying things on a given exercise, +// even after you already figured it out. If you got everything working and +// feel ready for the next exercise, you the `I AM NOT DONE` comment below. + +// I AM NOT DONE + fn main() { x = 5; println!("x has the value {}", x); diff --git a/exercises/variables/variables2.rs b/exercises/variables/variables2.rs index a0b4a37..e3c3b76 100644 --- a/exercises/variables/variables2.rs +++ b/exercises/variables/variables2.rs @@ -1,6 +1,8 @@ // variables2.rs // Make me compile! Scroll down for hints :) +// I AM NOT DONE + fn main() { let x; if x == 10 { diff --git a/exercises/variables/variables3.rs b/exercises/variables/variables3.rs index 165a277..7e3fd93 100644 --- a/exercises/variables/variables3.rs +++ b/exercises/variables/variables3.rs @@ -1,6 +1,8 @@ // variables3.rs // Make me compile! Scroll down for hints :) +// I AM NOT DONE + fn main() { let x = 3; println!("Number {}", x); diff --git a/exercises/variables/variables4.rs b/exercises/variables/variables4.rs index 71ebf0f..33eca9e 100644 --- a/exercises/variables/variables4.rs +++ b/exercises/variables/variables4.rs @@ -1,6 +1,8 @@ // variables4.rs // Make me compile! Scroll down for hints :) +// I AM NOT DONE + fn main() { let x: i32; println!("Number {}", x); |
