8000 OPEN THREAD: Exercises that you didn't like · Issue #13 · rust-lang/rustlings · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

OPEN THREAD: Exercises that you didn't like #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
carols10cents opened this issue Sep 23, 2015 · 4 comments
Closed

OPEN THREAD: Exercises that you didn't like #13

carols10cents opened this issue Sep 23, 2015 · 4 comments

Comments

@carols10cents
Copy link
Member

I'm going to leave this issue open basically forever, please feel free to leave a comment if you find any particular exercises to be:

  • too confusing
  • too frustrating
  • not useful for learning
  • otherwise don't fit your expectations

Please include which exercise you're discussing and explain as best you can what you didn't like about it :)

@dagoss
Copy link
dagoss commented Mar 17, 2016

I disliked move semantics 2. There was so many ways to solve it that I didn't feel like I found an intended solution (previously exercises up until that point felt like there was a "right" answer).

Borrowing and references in general seem to be a unique (and confusing) aspect of Rust. maybe a few exercises that are more varied could be helpful.

@carols10cents
Copy link
Member Author

@dagoss thank you so much for your feedback!!!!!! I'm seriously excited to find places where these can be improved :) I'll be sure to ping you when I have an update to get your thoughts!

@zwieberl
Copy link

Hi, first of all, thank you for your great exercises! They are really helpful, as I'm actually currently learning Rust.
A quite confusing aspect for me are Strings. You do have 3 exercises about these, but afterwards I didn't have the feeling that I knew what was going on.

Maybe a step-by-step exercise would be more helpful?
I came up with something like this (combining your first two string-exercises):

// String vs &str 
// Job 1: Make me compile using the function print_my_text as it is.
// Job 2: But this is inefficient! We copy "my_text" when giving it to the function.
//        Lets make it more efficient, by passing a reference of String instead!
// Job 3: But now we still need to add this weird function-call to make our text into a String, 
//        doing more work than we would need to. 
//        There is a different type, which we can use, so that everything still works, but without 
//        converting my_text to a String. You can do it! (A hint about the title of the exercise could be added)
// Job 4: Hey, but what if I _want_ to pass a String to my nifty little function? Well... You can! Try it!
//        Why does this work, but not the other way around? 

fn print_my_text(text : String) {
    println!("I was commanded to print: {}", text);
}

fn main() {
    let mut my_text = "Strings are weird!";
    print_my_text(my_text);
    my_text = "Something else!";
    print_my_text(my_text);
}

Your hints of the first two string-exercises could be added here as well (with slight modifications).
What do you think?

And there is also a really good article about this: http://hermanradtke.com/2015/05/03/string-vs-str-in-rust-functions.html
Could maybe be added to the literature?

@Wieke
Copy link
Wieke commented Jan 3, 2017

Just did all the exercises and they seem pretty good, though I have some comments on the categorized ones:

  • ex1.rs is a bit pointless as it compiles already.
  • ex2.rs appears to be the same as strings1.rs.
  • ex3.rs is unclear as to what the supposed solution is (I assume the point was to add #[derive(Debug)]).
  • ex4.rs appears to be the same as errors2.rs.
  • ex5.rs appears to be the same as move_semantics2.rs

@komaeda komaeda closed this as completed Jan 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
0