Devlog #1 (snakinal - a snake game in the terminal)
This is my first time in a long time doing something related to the terminal and also my first time with Rust 🦀 (I’ve fiddled with C++, so that background helps me connect to things in rust)! I’m going with a PBL (project based learning) route to quickly learn Rust (although I know Rust has a big learning curve). Also, shout out to Let’s Get Rusty’s rust learning playlist on YT.
Anyways, below I’ve managed to write something simple in the terminal through a bit of AI help. In this devlog I’ve learnt quite a bit of rust syntax:
- like how creating “classes” in rust has a 3 step procedure (
struct,impl, andtrait) instead of justclassin other low level languages -
!()are macros that executes before compile time -
?;is used on expressions that can return a success or fail, and to return the error immediately if it fails, also only works when the return type isResult<> - learnt a bit about how
crosstermlibrary functions work - also took me a year to understand why lsp/linting wouldn’t work for another file that I had. Apparently Rust doesn’t see files unless you do
mod <filename>inmain.rs - One more thing that still slightly confuses me is the difference between
::&.and when to use one or the other (so if someone doesn’t mind commenting, I’d really appreciate!)
I hope this pointers have helped other beginner rusties, and if I’ve said something incorrect, rustaceans pls forgive me