EDIT: If you read the gist before, I've updated it with my latest version. I'm pretty sure I took care of everyone's comments, thanks so much!
So! The new tutorial will be focused on building several small projects in Rust. This example is the first one: a classic 'guessing game.' This was one of the first programs I wrote when I first learned C. 😄
I'd like the feedback of the community before I actually start writing the guide. So this code will be the final code of the first real example Rust programmers see. So I want it to be good. I don't claim this code is good, I just worked something out real quick. Oh, and this is tracking master.
The idea is that I will slowly build from hello world to this final code in steps, introducing one concept at a time. Here are the concepts I'd like a Rust programmer to understand by the time they're done:
- If
- Functions
- return (wrt semicolons)
- comments
- Testing
- attributes
- stability markers
- Crates and Modules
- visibility
- Compound Data Types
- Tuples
- Structs
- Enums
- Match
- Looping
- for
- while
- loop
- break/continue
- iterators
This is the first Rust that I have seen, I purposefully kept my eyes shut to rust since you mentioned you were writing docs, so I could learn from your docs.... that sounds crazier written down then it did in my head :-/
For the number game: it's simple enough that I could follow along, made sense and peeked my interest, so thumbs up! 👍
If it helps what I found interesting was:
("Please input guess #{}", guesses + 1)
- interpolation? (probably the wrong terminology), took me a couple of glances to grok the syntax but that's because I'm used to rubylet mut guesses: int = 0;
- sweet syntax for assignmentfrom_str::<int>
- type casting?input.as_slice().trim_right()
- very descriptive and readable method chaining 😃match
- now that looks like a neato feature! Is it pattern matching per se? or more akin to the switch statement?The only negative thing that ran through my head was: it's probably still a pain to install and setup being so new to try this out locally. Completely unfounded I'm sure, I just noticed that it prevented me from doing it though.
Let me know if you'd be interested any other kind of feedback, hope that helps. Good luck!