-
Notifications
You must be signed in to change notification settings - Fork 10.6k
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
Comments
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. |
@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! |
Hi, first of all, thank you for your great exercises! They are really helpful, as I'm actually currently learning Rust. Maybe a step-by-step exercise would be more helpful? // 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). And there is also a really good article about this: http://hermanradtke.com/2015/05/03/string-vs-str-in-rust-functions.html |
Just did all the exercises and they seem pretty good, though I have some comments on the categorized ones:
|
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:
Please include which exercise you're discussing and explain as best you can what you didn't like about it :)
The text was updated successfully, but these errors were encountered: