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
Things which comes to my mind as a newbie when reading the code, just thinking loud:
There is no declaration for
generate_secret_number
before main 👍, comparing to C.There is no class, just two simple function with readable signatures, while main has no return type.
What's the purpose of
as_slice
is unknown to me. unwrap too as @nightpool mentioned.Pattern matching and immutability, new concept for a developer which comes from a non-functional background.
I think namespace including and
::
operator in different contexts like in line 20, needs description.And last thing is those values at the left side of string pattern matching, Less, Greater and Equal, are they same old constants or ...?
Thanks!